Handler.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Exceptions;
  3. use App\Http\Controllers\JsonResponseHelper;
  4. use App\Libraries\ChunkedUpload\Exceptions\UploadFailedException;
  5. use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
  6. use Throwable;
  7. class Handler extends ExceptionHandler
  8. {
  9. use JsonResponseHelper;
  10. /**
  11. * The list of the inputs that are never flashed to the session on validation exceptions.
  12. *
  13. * @var array<int, string>
  14. */
  15. protected $dontFlash = [
  16. 'current_password',
  17. 'password',
  18. 'password_confirmation',
  19. ];
  20. /**
  21. * Register the exception handling callbacks for the application.
  22. */
  23. public function register(): void
  24. {
  25. $this->reportable(function (Throwable $e) {
  26. return match (get_class($e)) {
  27. ValidationException::class => false,
  28. UploadFailedException::class => false,
  29. default => true,
  30. };
  31. });
  32. $this->renderable(fn(ValidationException $e) => $this->unprocesableEtity($e->getErrors(), message: $e->getMessage()));
  33. $this->renderable(fn(ValidationException $e) => $this->badRequest($e->getMessage()));
  34. }
  35. }