From 0fcfd313052ceec58fabca16cc3d56e3c26a9f98 Mon Sep 17 00:00:00 2001 From: boban Date: Sun, 14 Jun 2026 15:34:44 +0200 Subject: [PATCH] fix(errors): never let locale resolution break the error page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The withExceptions render hook called SetLocale::apply(), which resolves the user via the DB — if the original error was a DB/user-provider failure, that second access would throw inside the renderer and prevent the custom error page from rendering (exactly when it's needed). Wrap it so any failure is swallowed and the page renders in the default locale. Co-Authored-By: Claude Opus 4.8 (1M context) --- bootstrap/app.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bootstrap/app.php b/bootstrap/app.php index 912fa3f..52413c5 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -49,7 +49,15 @@ return Application::configure(basePath: dirname(__DIR__)) // it too (R16); returning null falls through to the normal renderer (the // resources/views/errors/* views). $exceptions->render(function (Throwable $e, Request $request) { - SetLocale::apply($request); + // Best-effort: locale resolution touches the session/user, which can be the + // very thing that failed (e.g. a DB outage). Swallow any error so this hook + // can never throw a second exception and break the custom error page — the + // page just renders in the default locale instead. + try { + SetLocale::apply($request); + } catch (Throwable) { + // keep the default locale + } return null; });