Skip to content

Commit

Permalink
🧑‍💻 add context to error log
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKrisKrisu committed Jan 14, 2025
1 parent f73ae81 commit c043ffb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}

0 comments on commit c043ffb

Please sign in to comment.