1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace App\Exceptions;
- use App\Http\Controllers\JsonResponseHelper;
- use App\Libraries\ChunkedUpload\Exceptions\UploadFailedException;
- use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
- use Throwable;
- class Handler extends ExceptionHandler
- {
- use JsonResponseHelper;
- /**
- * The list of the inputs that are never flashed to the session on validation exceptions.
- *
- * @var array<int, string>
- */
- protected $dontFlash = [
- 'current_password',
- 'password',
- 'password_confirmation',
- ];
- /**
- * Register the exception handling callbacks for the application.
- */
- public function register(): void
- {
- $this->reportable(function (Throwable $e) {
- return match (get_class($e)) {
- ValidationException::class => false,
- UploadFailedException::class => false,
- default => true,
- };
- });
- $this->renderable(fn(ValidationException $e) => $this->unprocesableEtity($e->getErrors(), message: $e->getMessage()));
- $this->renderable(fn(ValidationException $e) => $this->badRequest($e->getMessage()));
- }
- }
|