Skip to content

Commit 5c95c92

Browse files
authored
Update Handler.php compatibility with Laravel Pulse (#41)
* Update Handler.php * Update Handler.php
1 parent dfeb976 commit 5c95c92

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/Exception/Handler.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Dingo\Api\Exception;
44

5+
use Closure;
56
use Dingo\Api\Http\Request;
67
use Exception;
78
use Illuminate\Database\Eloquent\ModelNotFoundException;
@@ -10,6 +11,7 @@
1011
use Dingo\Api\Contract\Debug\ExceptionHandler;
1112
use Dingo\Api\Contract\Debug\MessageBagErrors;
1213
use Illuminate\Contracts\Debug\ExceptionHandler as IlluminateExceptionHandler;
14+
use Illuminate\Foundation\Exceptions\ReportableHandler;
1315
use Illuminate\Validation\ValidationException;
1416
use ReflectionFunction;
1517
use Symfony\Component\Console\Output\OutputInterface;
@@ -397,4 +399,21 @@ public function setDebug($debug)
397399
{
398400
$this->debug = $debug;
399401
}
402+
403+
/**
404+
* Register a reportable callback.
405+
*
406+
* @param callable $reportUsing
407+
* @return \Illuminate\Foundation\Exceptions\ReportableHandler
408+
*/
409+
public function reportable(callable $reportUsing)
410+
{
411+
if (! $reportUsing instanceof Closure) {
412+
$reportUsing = Closure::fromCallable($reportUsing);
413+
}
414+
415+
return tap(new ReportableHandler($reportUsing), function ($callback) {
416+
$this->reportCallbacks[] = $callback;
417+
});
418+
}
400419
}

0 commit comments

Comments
 (0)