From c043ffb5a6b8bf6708a7af45fddde6fe29ecbb7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20St=C3=B6ckel?= Date: Tue, 14 Jan 2025 09:14:42 +0100 Subject: [PATCH] :technologist: add context to error log --- app/Exceptions/Handler.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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(); + } + } }