Skip to content

Commit e789c89

Browse files
committed
refactor: improved error handling logic
1 parent dd52aa8 commit e789c89

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

bootstrap/app.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,14 @@
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+
// Show Inertia response modal for debugging
56+
return $response;
57+
} elseif (!$request->inertia()) {
5158
// Show error page component for standard visits
5259
return Inertia::render('Error', [
5360
'errorTitles' => $errorTitles,
@@ -62,10 +69,6 @@
6269
->toResponse($request)
6370
->setStatusCode($statusCode);
6471
} else {
65-
// Show standard modal for easier debugging locally
66-
if (app()->hasDebugModeEnabled() && $statusCode === 500) {
67-
return $response;
68-
}
6972
// Return JSON response for PrimeVue toast to display, handled by Inertia router event listener
7073
$errorSummary = "$statusCode - $errorTitles[$statusCode]";
7174
$errorDetail = $errorDetails[$statusCode];

0 commit comments

Comments
 (0)