protected function exceptionToArray($exception)
{
$array = ['name' => get_class($exception), 'message' => $exception->getMessage(), 'code' => $exception->getCode()];
if ($exception instanceof HttpException) {
$array['status'] = $exception->statusCode;
}
if ($this->debug) {
$array['file'] = $exception->getFile();
$array['line'] = $exception->getLine();
$array['trace'] = explode("\n", $exception->getTraceAsString());
}
if (($prev = $exception->getPrevious()) !== null) {
$array['previous'] = $this->exceptionToArray($prev);
}
return $array;
}