toby/app/Architecture/ExceptionHandler.php
Ewelina Lasowy fdbc374d7e
#93 - custom error pages (#94)
* #93 - wip

* #93 - wip

* #93 - fix if statement

* #93 - wip

* #93 - added default error page

* #93 - fix to error page

* #93 - fix linter

* #93 - delete unnecessary file

* #93 - added EOL

* #93 - fix

* #93 - cr fix

Co-authored-by: Adrian Hopek <adrian.hopek@blumilk.pl>
2022-03-30 09:06:25 +02:00

35 lines
842 B
PHP

<?php
declare(strict_types=1);
namespace Toby\Architecture;
use Illuminate\Foundation\Exceptions\Handler;
use Inertia\Inertia;
use Symfony\Component\HttpFoundation\Response;
use Throwable;
class ExceptionHandler extends Handler
{
protected $dontFlash = [
"current_password",
"password",
"password_confirmation",
];
public function render($request, Throwable $e): Response
{
$response = parent::render($request, $e);
if (app()->environment("production") && in_array($response->status(), [500, 503, 429, 419, 404, 403, 401], true)) {
return Inertia::render("Error", [
"status" => $response->status(),
])
->toResponse($request)
->setStatusCode($response->status());
}
return $response;
}
}