| Conditions | 7 |
| Paths | 12 |
| Total Lines | 23 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 7.0222 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | 4 | protected function convertExceptionToArray($exception) |
|
| 14 | { |
||
| 15 | 4 | if (!YII_DEBUG && !$exception instanceof UserException && !$exception instanceof HttpException) { |
|
| 16 | $exception = new Exception(Yii::t('yii', 'An internal server error occurred.'), 500); |
||
| 17 | } |
||
| 18 | |||
| 19 | $payload = [ |
||
| 20 | 4 | 'status' => Status::ERROR, |
|
| 21 | 4 | 'message' => $exception->getMessage(), |
|
| 22 | 4 | 'code' => $exception->getCode(), |
|
| 23 | ]; |
||
| 24 | 4 | if ($exception instanceof Exception) { |
|
| 25 | 1 | $payload['data'] = $exception->getData(); |
|
| 26 | } |
||
| 27 | |||
| 28 | 4 | if (YII_DEBUG) { |
|
| 29 | 4 | $payload['debug']['traces'] = explode("\n", $exception->getTraceAsString()); |
|
| 30 | 4 | if (($prev = $exception->getPrevious()) !== null) { |
|
| 31 | 1 | $payload['debug']['previous'] = $this->convertExceptionToArray($prev); |
|
| 32 | } |
||
| 33 | } |
||
| 34 | |||
| 35 | 4 | return $payload; |
|
| 36 | } |
||
| 38 |