Commit 9e9b3548 by Qiang Xue

refactor Exception::toArrayRecursive().

parent a4a15963
......@@ -39,21 +39,12 @@ class Exception extends \Exception implements Arrayable
*/
protected function toArrayRecursive($exception)
{
if ($exception instanceof self) {
$array = array(
'type' => get_class($exception),
'name' => $exception->getName(),
'name' => $exception instanceof self ? $exception->getName() : 'Exception',
'message' => $exception->getMessage(),
'code' => $exception->getCode(),
);
} else {
$array = array(
'type' => get_class($exception),
'name' => 'Exception',
'message' => $exception->getMessage(),
'code' => $exception->getCode(),
);
}
if (($prev = $exception->getPrevious()) !== null) {
$array['previous'] = $this->toArrayRecursive($prev);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment