| 1 | <?php |
||
| 14 | class UsageException extends Exception { |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var string |
||
| 18 | */ |
||
| 19 | private $apiCode; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var array |
||
| 23 | */ |
||
| 24 | private $result; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var string |
||
| 28 | */ |
||
| 29 | private $rawMessage; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @since 0.1 |
||
| 33 | * |
||
| 34 | * @param string $apiCode |
||
| 35 | * @param string $message |
||
| 36 | * @param array $result the result the exception was generated from |
||
| 37 | */ |
||
| 38 | 2 | public function __construct( $apiCode = '', $message = '', $result = array() ) { |
|
| 39 | 2 | $this->apiCode = $apiCode; |
|
| 40 | 2 | $this->result = $result; |
|
| 41 | 2 | $this->rawMessage = $message; |
|
| 42 | 2 | $message = 'Code: ' . $apiCode . PHP_EOL . |
|
| 43 | 2 | 'Message: ' . $message . PHP_EOL . |
|
| 44 | 2 | 'Result: ' . json_encode( $result ); |
|
| 45 | 2 | parent::__construct( $message, 0, null ); |
|
| 46 | 2 | } |
|
| 47 | |||
| 48 | /** |
||
| 49 | * @since 0.1 |
||
| 50 | * |
||
| 51 | * @return string |
||
| 52 | */ |
||
| 53 | 2 | public function getApiCode() { |
|
| 56 | |||
| 57 | /** |
||
| 58 | * @since 0.3 |
||
| 59 | * |
||
| 60 | * @return array |
||
| 61 | */ |
||
| 62 | 2 | public function getApiResult() { |
|
| 65 | |||
| 66 | /** |
||
| 67 | * @since 2.3.0 |
||
| 68 | * |
||
| 69 | * @return string |
||
| 70 | */ |
||
| 71 | public function getRawMessage() { |
||
| 74 | |||
| 75 | } |
||
| 76 |