diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 1c1b36b11..bc6698871 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -73,4 +73,20 @@ public function render($request, Throwable $exception) { return $response; } + + /** + * Builds the exception's context array. + * + * @return array + */ + protected function context(): array { + try { + return array_merge(parent::context(), [ + 'url' => request()?->fullUrl(), + ]); + } catch (Throwable) { + // If request() is not available (e.g. in Artisan commands), return the default context. + return parent::context(); + } + } }