Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
ReadingListRepositoryException | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
getMessageObject | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\ReadingLists; |
4 | |
5 | use Exception; |
6 | use MediaWiki\Exception\ILocalizedException; |
7 | use MediaWiki\Message\Message; |
8 | |
9 | /** |
10 | * Used by ReadingListRepository methods when performing the method would violate some kind of |
11 | * constraint (e.g. trying to add an entry to a list owned by a different user). Usually this is |
12 | * a client error; in some cases it could happen for otherwise sane calls due to race conditions. |
13 | */ |
14 | class ReadingListRepositoryException extends Exception implements ILocalizedException { |
15 | |
16 | /** @var Message */ |
17 | private $messageObject; |
18 | |
19 | /** |
20 | * @param string $messageKey MediaWiki message key for describing the error. |
21 | * @param array $params Parameters for the message. |
22 | */ |
23 | public function __construct( $messageKey, array $params = [] ) { |
24 | $this->messageObject = new Message( $messageKey, $params ); |
25 | $messageText = $this->messageObject->inLanguage( 'en' )->useDatabase( false )->text(); |
26 | parent::__construct( "$messageText ($messageKey)" ); |
27 | } |
28 | |
29 | /** |
30 | * @return Message |
31 | */ |
32 | public function getMessageObject() { |
33 | return $this->messageObject; |
34 | } |
35 | |
36 | } |