Skip to content

Commit

Permalink
Added: API response and validation are ignored from exceptions log
Browse files Browse the repository at this point in the history
  • Loading branch information
Suraj Datheputhe committed Jan 13, 2025
1 parent 660f5f8 commit 8db87ea
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ApiResponseServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -13,6 +15,7 @@ class ApiResponseServiceProvider extends ServiceProvider
public function register(): void
{
$this->registerFacades();
$this->app->singleton(ExceptionHandler::class, ApiExceptionHandler::class);
}

/**
Expand Down
32 changes: 32 additions & 0 deletions src/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace SurazDott\ApiResponse\Exceptions;

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;

class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<Throwable>>
*/
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);
}
}

0 comments on commit 8db87ea

Please sign in to comment.