From 2b00cf9178c7ccabf76d7da05a0458fe7c1b678a Mon Sep 17 00:00:00 2001 From: Connor Abbas Date: Fri, 8 Aug 2025 00:38:08 +0000 Subject: [PATCH] refactor: better error handling --- bootstrap/app.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bootstrap/app.php b/bootstrap/app.php index 6ceeee60..68d9d8f2 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -47,7 +47,13 @@ ]; if (in_array($statusCode, [500, 503, 404, 403])) { - if (!$request->inertia()) { + if ( + $statusCode === 500 + && app()->hasDebugModeEnabled() + && get_class($exception) !== ErrorToastException::class + ) { + return $response; + } elseif (!$request->inertia()) { // Show error page component for standard visits return Inertia::render('Error', [ 'errorTitles' => $errorTitles, @@ -62,10 +68,6 @@ ->toResponse($request) ->setStatusCode($statusCode); } else { - // Show standard modal for easier debugging locally - if (app()->hasDebugModeEnabled() && $statusCode === 500) { - return $response; - } // Return JSON response for PrimeVue toast to display, handled by Inertia router event listener $errorSummary = "$statusCode - $errorTitles[$statusCode]"; $errorDetail = $errorDetails[$statusCode];