Skip to content

Commit c043ffb

Browse files
committed
🧑‍💻 add context to error log
1 parent f73ae81 commit c043ffb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Diff for: app/Exceptions/Handler.php

+16
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,20 @@ public function render($request, Throwable $exception) {
7373

7474
return $response;
7575
}
76+
77+
/**
78+
* Builds the exception's context array.
79+
*
80+
* @return array
81+
*/
82+
protected function context(): array {
83+
try {
84+
return array_merge(parent::context(), [
85+
'url' => request()?->fullUrl(),
86+
]);
87+
} catch (Throwable) {
88+
// If request() is not available (e.g. in Artisan commands), return the default context.
89+
return parent::context();
90+
}
91+
}
7692
}

0 commit comments

Comments
 (0)