/** * @param \Exception $e * * @return WebhookResponse */ public static function fromException(\Exception $e) { if ($e instanceof XsollaWebhookException) { return static::fromErrorCode($e->getXsollaErrorCode(), $e->getMessage(), $e->getHttpStatusCode()); } else { return static::fromErrorCode('FATAL_ERROR', $e->getMessage()); } }
/** * @param \Exception $data * @param int $status * @param array $headers */ public function __construct(\Exception $data, $status = Response::HTTP_INTERNAL_SERVER_ERROR, $headers = array()) { if ($data instanceof CriticalExceptionInterface) { $status = $data->getHttpStatusCode(); } elseif ($data instanceof UncriticalExceptionInterface) { $status = Response::HTTP_OK; } parent::__construct($data, $status, $headers); $this->headers->set('X-Status-Code', $status); }
/** * The render function will take a `SymphonyErrorPage` exception and * output a HTML page. This function first checks to see if their is a custom * template for this exception otherwise it reverts to using the default * `usererror.generic.php` * * @param Exception $e * The Exception object * @return string * An HTML string */ public static function render(Exception $e) { if ($e->getTemplate() === false) { Page::renderStatusCode($e->getHttpStatusCode()); if (isset($e->getAdditional()->header)) { header($e->getAdditional()->header); } echo '<h1>Symphony Fatal Error</h1><p>' . $e->getMessage() . '</p>'; exit; } include $e->getTemplate(); }
private function prepareHttpResponse(\Exception $exception) : JsonResponse { $responseBodyArray = ['error-message' => 'We\'re sorry, an internal server error occurred.']; $statusCode = $exception instanceof ExceptionWithHttpStatus ? $exception->getHttpStatusCode() : 500; return new JsonResponse($responseBodyArray, $statusCode); }