Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
namespace App\Exceptions;

use Throwable;
use Illuminate\Http\Request;
use Sentry\Laravel\Integration;
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Routing\Exceptions\InvalidSignatureException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;

class Handler extends ExceptionHandler
{
Expand All @@ -21,6 +24,19 @@ public function register(): void
Integration::captureUnhandledException($e);
});

// Livewire shows a failed update's response in a modal and boots the page in it. The app's error
// pages mount the layout's components, which the update endpoint signs without the path of a page,
// so every update they send would be rejected. The endpoint answers with the status text instead.
$this->renderable(function (HttpExceptionInterface $exception, Request $request) {
if (! $request->routeIs('*livewire.update')) {
return null;
}

$statusCode = $exception->getStatusCode();

return response(Response::$statusTexts[$statusCode] ?? '', $statusCode, $exception->getHeaders());
});

$this->renderable(function (InvalidSignatureException $e) {
return response()->view('errors.link-expired', [], 403);
});
Expand Down
Loading
Loading