Handler.php 954 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Exceptions;
  4. use Hypervel\Foundation\Exceptions\Handler as ExceptionHandler;
  5. use Hypervel\Http\Request;
  6. use Throwable;
  7. class Handler extends ExceptionHandler
  8. {
  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 array $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. // return json when path start with `api`
  25. $this->shouldRenderJsonWhen(function (Request $request, Throwable $e) {
  26. return str_starts_with($path = $request->path(), 'api')
  27. && (strlen($path) === 3 || $path[3] === '/');
  28. });
  29. $this->reportable(function (Throwable $e) {
  30. });
  31. }
  32. }