Skip to content

Commit 2b00cf9

Browse files
committed
refactor: better error handling
1 parent 5331c90 commit 2b00cf9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

bootstrap/app.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@
4747
];
4848

4949
if (in_array($statusCode, [500, 503, 404, 403])) {
50-
if (!$request->inertia()) {
50+
if (
51+
$statusCode === 500
52+
&& app()->hasDebugModeEnabled()
53+
&& get_class($exception) !== ErrorToastException::class
54+
) {
55+
return $response;
56+
} elseif (!$request->inertia()) {
5157
// Show error page component for standard visits
5258
return Inertia::render('Error', [
5359
'errorTitles' => $errorTitles,
@@ -62,10 +68,6 @@
6268
->toResponse($request)
6369
->setStatusCode($statusCode);
6470
} else {
65-
// Show standard modal for easier debugging locally
66-
if (app()->hasDebugModeEnabled() && $statusCode === 500) {
67-
return $response;
68-
}
6971
// Return JSON response for PrimeVue toast to display, handled by Inertia router event listener
7072
$errorSummary = "$statusCode - $errorTitles[$statusCode]";
7173
$errorDetail = $errorDetails[$statusCode];

0 commit comments

Comments
 (0)