Can't you just show the exception, and have a button on the same page to link to (whatever page).
Aug 17, 2025
2
Level 2
handle laravel exception in livewire
My backend logic exists in vendor, so I do not access the logic, and in some cases, it throws exceptions
For front, I use Livewire when an exception tis hrown, the Livewire shows 404, 403 , 401 ... blade.php files
I did something like this in bootstrap/app.php
->withExceptions(function (Exceptions $exceptions): void {
$exceptions->render(function (Exception $e, Request $request) {
if ($request->is('livewire/update')) {
if (
$e instanceof AuthorizationException ||
$e instanceof AccessDeniedHttpException
) {
return redirect()->back()->with('error-toast', $e->getMessage());
}
}
});
})
But since the Ajax request from Livewire gets 302 and is redirected to the back URL the flash data will be destroyed before using
And by the way, I do not like this approach. I want to tell Livewire an exception happened do something about it. what should I do?
Please or to participate in this conversation.