Skip to content

Instantly share code, notes, and snippets.

@mbpcoder
Last active June 30, 2017 20:00
Show Gist options
  • Select an option

  • Save mbpcoder/a6a2b82c03df337020ca987eae534dbb to your computer and use it in GitHub Desktop.

Select an option

Save mbpcoder/a6a2b82c03df337020ca987eae534dbb to your computer and use it in GitHub Desktop.
My render function in Laravel exception Handler Class
public function render($request, Exception $exception)
{
$statusCode = 0;
if ($this->isHttpException($exception)) {
$statusCode = $exception->getStatusCode();
}
if (in_array($statusCode, [401, 403, 404, 503])) {
return $this->renderHttpException($exception);
} elseif (app()->environment() == 'production') {
// Custom error 500 view on production
return response()->view("errors.general");
}
return parent::render($request, $exception);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment