| Conditions | 5 |
| Paths | 10 |
| Total Lines | 24 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | public static function createThrowable(ClientException $clientException) |
||
| 14 | { |
||
| 15 | $data = \GuzzleHttp\json_decode($clientException->getResponse()->getBody()->getContents()); |
||
| 16 | |||
| 17 | $code = 0; |
||
| 18 | $message = ''; |
||
| 19 | |||
| 20 | if (!empty($data->error)) { |
||
| 21 | $error = $data->error; |
||
| 22 | if (!empty($error->code)) { |
||
| 23 | $code = $error->code; |
||
| 24 | } |
||
| 25 | |||
| 26 | if (!empty($error->message)) { |
||
| 27 | $message = $error->message; |
||
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | if ($code == SearchLimitException::EXCEPTION_CODE) { |
||
| 32 | return new SearchLimitException($message); |
||
| 33 | } |
||
| 34 | |||
| 35 | return new ApiException($message, $code); |
||
| 36 | } |
||
| 37 | } |
||
| 38 |