fix(errors): never let locale resolution break the error page

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) <noreply@anthropic.com>
feat/v1-foundation
boban 2026-06-14 15:34:44 +02:00
parent d132efd861
commit 0fcfd31305
1 changed files with 9 additions and 1 deletions

View File

@ -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;
});