3

When server is down, for every request MaintenanceModeException is thrown and resources/views/errors/503.blade.php is rendered. I'm trying to change it's path but can't figure out where is that exceptions treatment and 503 response.

Matheus Simon
  • 668
  • 11
  • 34

1 Answers1

9

All http exceptions are handled by the renderHttpException() method inside \Illuminate\Foundation\Exceptions\Handler.php

/**
 * Render the given HttpException.
 *
 * @param  \Symfony\Component\HttpKernel\Exception\HttpException  $e
 * @return \Symfony\Component\HttpFoundation\Response
 */
protected function renderHttpException(HttpException $e)
{
    $status = $e->getStatusCode();

    if (view()->exists("errors.{$status}")) {
        return response()->view("errors.{$status}", ['exception' => $e], $status, $e->getHeaders());
    } else {
        return $this->convertExceptionToResponse($e);
    }
}

I assume you want to display a custom view for that 503 exception. In this case, just create your own 503.blade.php file inside resources/views/errors.

Diego Vidal
  • 1,022
  • 12
  • 21
  • 7
    You can run `artisan vendor:publish --tag=laravel-errors` to create all laravel error page templates in `resources/views/errros`. – Lars Nyström Jul 08 '19 at 14:41