1 | <?php |
||||
2 | /** |
||||
3 | * ErrorResult |
||||
4 | * The error result class. |
||||
5 | * |
||||
6 | * @package Elgg.Core |
||||
7 | * @subpackage WebServicesAPI |
||||
8 | */ |
||||
9 | class ErrorResult extends GenericResult { |
||||
10 | // Fail with no specific code |
||||
11 | public static $RESULT_FAIL = -1 ; |
||||
12 | |||||
13 | public static $RESULT_FAIL_APIKEY_DISABLED = -30; |
||||
14 | public static $RESULT_FAIL_APIKEY_INACTIVE = -31; |
||||
15 | public static $RESULT_FAIL_APIKEY_INVALID = -32; |
||||
16 | |||||
17 | // Invalid, expired or missing auth token |
||||
18 | public static $RESULT_FAIL_AUTHTOKEN = -20; |
||||
19 | |||||
20 | /** |
||||
21 | * A new error result |
||||
22 | * |
||||
23 | * @param string $message Message |
||||
24 | * @param int $code Error Code |
||||
25 | * @param Exception $exception Exception object |
||||
26 | * |
||||
27 | * @return void |
||||
28 | */ |
||||
29 | public function __construct($message, $code = "", Exception $exception = null) { |
||||
30 | if ($code == "") { |
||||
31 | $code = ErrorResult::$RESULT_FAIL; |
||||
32 | } |
||||
33 | |||||
34 | if ($exception != null) { |
||||
35 | $this->setResult($exception->__toString()); |
||||
36 | } |
||||
37 | |||||
38 | $this->setStatusCode($code, $message); |
||||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
39 | } |
||||
40 | |||||
41 | /** |
||||
42 | * Get a new instance of the ErrorResult. |
||||
43 | * |
||||
44 | * @param string $message Message |
||||
45 | * @param int $code Code |
||||
46 | * @param Exception $exception Optional exception for generating a stack trace. |
||||
47 | * |
||||
48 | * @return ErrorResult |
||||
49 | */ |
||||
50 | public static function getInstance($message, $code = "", Exception $exception = null) { |
||||
51 | // Return a new error object. |
||||
52 | return new ErrorResult($message, $code, $exception); |
||||
0 ignored issues
–
show
It seems like
$code can also be of type string ; however, parameter $code of ErrorResult::__construct() does only seem to accept integer , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
53 | } |
||||
54 | } |
||||
55 |