Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| InvalidInputException | |
0.00% |
0 / 13 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| getErrorCodeList | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| report | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Flow\Exception; |
| 4 | |
| 5 | use MediaWiki\Exception\ErrorPageError; |
| 6 | |
| 7 | /** |
| 8 | * Category: invalid input exception |
| 9 | * |
| 10 | * This is not logged, and must *only* be used when the error is caused by invalid end-user |
| 11 | * input. The same applies to the subclasses. |
| 12 | * |
| 13 | * If it is a logic error (including a missing or incorrect parameter not directly caused |
| 14 | * by user input), or another kind of failure, another (loggable) exception must be used. |
| 15 | */ |
| 16 | class InvalidInputException extends ErrorPageError { |
| 17 | |
| 18 | public function __construct( $message, $code = 'default' ) { |
| 19 | $list = $this->getErrorCodeList(); |
| 20 | if ( !in_array( $code, $list ) ) { |
| 21 | $code = 'default'; |
| 22 | } |
| 23 | parent::__construct( 'errorpagetitle', "flow-error-$code" ); |
| 24 | } |
| 25 | |
| 26 | protected function getErrorCodeList() { |
| 27 | // Comments are i18n messages, for grepping |
| 28 | return [ |
| 29 | 'invalid-input', |
| 30 | // flow-error-invalid-input |
| 31 | 'missing-revision', |
| 32 | // flow-error-missing-revision |
| 33 | 'revision-comparison', |
| 34 | // flow-error-revision-comparison |
| 35 | 'invalid-workflow', |
| 36 | // flow-error-invalid-workflow |
| 37 | ]; |
| 38 | } |
| 39 | |
| 40 | public function report( $action = ErrorPageError::SEND_OUTPUT ) { |
| 41 | global $wgOut; |
| 42 | $wgOut->setStatusCode( 400 ); |
| 43 | parent::report( $action ); |
| 44 | } |
| 45 | |
| 46 | } |