diff --git a/app/Architecture/ExceptionHandler.php b/app/Architecture/ExceptionHandler.php index 746f3e1..c63890d 100644 --- a/app/Architecture/ExceptionHandler.php +++ b/app/Architecture/ExceptionHandler.php @@ -5,6 +5,9 @@ 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 { @@ -13,4 +16,19 @@ class ExceptionHandler extends Handler "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; + } } diff --git a/resources/js/Pages/Error.vue b/resources/js/Pages/Error.vue new file mode 100644 index 0000000..76bfd45 --- /dev/null +++ b/resources/js/Pages/Error.vue @@ -0,0 +1,84 @@ + + + diff --git a/resources/js/Shared/Pagination.vue b/resources/js/Shared/Pagination.vue index 3cd59e6..4e5975c 100644 --- a/resources/js/Shared/Pagination.vue +++ b/resources/js/Shared/Pagination.vue @@ -21,11 +21,11 @@