From 8db87ea50c119f3d2ed7e99115b56578ab03b142 Mon Sep 17 00:00:00 2001 From: Suraj Datheputhe <3165404-surajdatheputhe@users.noreply.gitlab.com> Date: Mon, 13 Jan 2025 13:52:13 +0545 Subject: [PATCH] Added: API response and validation are ignored from exceptions log --- src/ApiResponseServiceProvider.php | 3 +++ src/Exceptions/Handler.php | 32 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/Exceptions/Handler.php 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); + } +}