Skip to content

Commit

Permalink
Refactor(src): Improve exception reporting
Browse files Browse the repository at this point in the history
- Use bindTo() to bind reportUsing closure to exceptionHandler
- Remove unnecessary closure conversion
  • Loading branch information
guanguans committed Aug 20, 2023
1 parent 969916e commit 632baae
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ExceptionNotifyServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ protected function extendExceptionHandler(): self

/** @var callable(\Throwable):mixed|void $reportUsing */
$reportUsing = $reportUsingCreator($exceptionHandler);
if (! $reportUsing instanceof \Closure) {
$reportUsing = \Closure::fromCallable($reportUsing);
if ($reportUsing instanceof \Closure) {
$reportUsing = $reportUsing->bindTo($exceptionHandler, $exceptionHandler);
}

$exceptionHandler->reportable($reportUsing->bindTo($exceptionHandler, $exceptionHandler));
$exceptionHandler->reportable($reportUsing);
}

return $exceptionHandler;
Expand Down

0 comments on commit 632baae

Please sign in to comment.