Skip to content

Commit

Permalink
fix(#66): improve exception handling in ExceptionNotifyServiceProvider
Browse files Browse the repository at this point in the history
- Add a check for method existence before calling reportable function in extendExceptionHandler method
  • Loading branch information
guanguans committed May 13, 2024
1 parent 8db8040 commit b0b4f82
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/ExceptionNotifyServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ protected function registerTestCommand(): self
protected function extendExceptionHandler(): self
{
$this->app->extend(ExceptionHandler::class, function (ExceptionHandler $exceptionHandler): ExceptionHandler {
if ($reportUsingCreator = config('exception-notify.report_using_creator')) {
if (
($reportUsingCreator = config('exception-notify.report_using_creator'))
&& method_exists($exceptionHandler, 'reportable')
) {
/** @var callable(ExceptionHandler):callable|class-string $reportUsingCreator */
if (\is_string($reportUsingCreator) && class_exists($reportUsingCreator)) {
$reportUsingCreator = $this->app->make($reportUsingCreator);
Expand Down

0 comments on commit b0b4f82

Please sign in to comment.