Skip to content

Commit 527b288

Browse files
Add method to be able to override the exception context format (#44895)
* Add method to be able to override the exception context format * Fix style * formatting * Update Handler.php Co-authored-by: Taylor Otwell <[email protected]>
1 parent ea88e2e commit 527b288

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/Illuminate/Foundation/Exceptions/Handler.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,7 @@ public function report(Throwable $e)
268268
$this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR
269269
);
270270

271-
$context = array_merge(
272-
$this->exceptionContext($e),
273-
$this->context(),
274-
['exception' => $e]
275-
);
271+
$context = $this->buildExceptionContext($e);
276272

277273
method_exists($logger, $level)
278274
? $logger->{$level}($e->getMessage(), $context)
@@ -303,6 +299,21 @@ protected function shouldntReport(Throwable $e)
303299
return ! is_null(Arr::first($dontReport, fn ($type) => $e instanceof $type));
304300
}
305301

302+
/**
303+
* Create the context array for logging the given exception.
304+
*
305+
* @param \Throwable $e
306+
* @return array
307+
*/
308+
protected function buildExceptionContext(Throwable $e)
309+
{
310+
return array_merge(
311+
$this->exceptionContext($e),
312+
$this->context(),
313+
['exception' => $e]
314+
);
315+
}
316+
306317
/**
307318
* Get the default exception context variables for logging.
308319
*

0 commit comments

Comments
 (0)