static public function create(\Exception $exception)
{
$e = new static();
$e->setMessage($exception->getMessage());
$e->setCode($exception->getCode());
$e->setTrace($exception->getTrace(), $exception->getFile(), $exception->getLine());
$e->setClass(get_class($exception));
if ($exception->getPrevious()) {
$e->setPrevious(static::create($exception->getPrevious()));
}
$e->setStatusCode($exception instanceof HttpException ? $exception->getCode() : 500);
return $e;
}