public static function create(\Exception $exception, $statusCode = null, array $headers = array()) {
$e = new static();
$e
->setMessage($exception
->getMessage());
$e
->setCode($exception
->getCode());
if ($exception instanceof HttpExceptionInterface) {
$statusCode = $exception
->getStatusCode();
$headers = array_merge($headers, $exception
->getHeaders());
}
if (null === $statusCode) {
$statusCode = 500;
}
$e
->setStatusCode($statusCode);
$e
->setHeaders($headers);
$e
->setTraceFromException($exception);
$e
->setClass(get_class($exception));
$e
->setFile($exception
->getFile());
$e
->setLine($exception
->getLine());
if ($exception
->getPrevious()) {
$e
->setPrevious(static::create($exception
->getPrevious()));
}
return $e;
}