Handler.php 953 B

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