From c0d926429608d81de12c4a558c1c27dcc762aaf9 Mon Sep 17 00:00:00 2001 From: Adrian Hopek Date: Mon, 28 Mar 2022 07:46:11 +0200 Subject: [PATCH] #93 - fix if statement --- app/Architecture/ExceptionHandler.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/Architecture/ExceptionHandler.php b/app/Architecture/ExceptionHandler.php index 7a01fd0..5bf05d7 100644 --- a/app/Architecture/ExceptionHandler.php +++ b/app/Architecture/ExceptionHandler.php @@ -6,6 +6,7 @@ namespace Toby\Architecture; use Illuminate\Foundation\Exceptions\Handler; use Inertia\Inertia; +use Symfony\Component\HttpFoundation\Response; use Throwable; class ExceptionHandler extends Handler @@ -16,17 +17,21 @@ class ExceptionHandler extends Handler "password_confirmation", ]; - public function render($request, Throwable $e) + public function render($request, Throwable $e): Response { $response = parent::render($request, $e); - if (!app()->environment(['local', 'testing']) && in_array($response->status(), [500, 503, 404, 403])) { - return Inertia::render('Error', ['status' => $response->status()]) + if (!app()->environment(["local", "testing"]) && in_array($response->status(), [500, 503, 404, 403], true)) { + return Inertia::render("Error", [ + "status" => $response->status(), + ]) ->toResponse($request) ->setStatusCode($response->status()); - } else if ($response->status() === 419) { + } + + if ($response->status() === 419) { return back()->with([ - 'message' => 'The page expired, please try again.', + "message" => "The page expired, please try again.", ]); }