diff --git a/src/ApiResponseServiceProvider.php b/src/ApiResponseServiceProvider.php index 6931c48..30e71b3 100644 --- a/src/ApiResponseServiceProvider.php +++ b/src/ApiResponseServiceProvider.php @@ -2,7 +2,9 @@ namespace SurazDott\ApiResponse; +use Illuminate\Contracts\Debug\ExceptionHandler; use Illuminate\Support\ServiceProvider; +use SurazDott\ApiResponse\Exceptions\Handler as ApiExceptionHandler; use SurazDott\ApiResponse\Http\ApiResponse; class ApiResponseServiceProvider extends ServiceProvider @@ -13,6 +15,7 @@ class ApiResponseServiceProvider extends ServiceProvider public function register(): void { $this->registerFacades(); + $this->app->singleton(ExceptionHandler::class, ApiExceptionHandler::class); } /** diff --git a/src/Exceptions/Handler.php b/src/Exceptions/Handler.php new file mode 100644 index 0000000..032d8eb --- /dev/null +++ b/src/Exceptions/Handler.php @@ -0,0 +1,32 @@ +> + */ + protected $dontReport = [ + \SurazDott\ApiResponse\Exceptions\ApiValidationException::class, + \SurazDott\ApiResponse\Exceptions\ApiResponseException::class, + ]; + + /** + * Report or log an exception. + * + * @param \Throwable $exception + * @return void + * + * @throws \Exception + */ + public function report(Throwable $exception): void + { + parent::report($exception); + } +}