Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

65 lignes
1.8 KiB

  1. <?php
  2. namespace App\Exceptions;
  3. use Exception;
  4. use Illuminate\Auth\AuthenticationException;
  5. use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
  6. class Handler extends ExceptionHandler
  7. {
  8. /**
  9. * A list of the exception types that should not be reported.
  10. *
  11. * @var array
  12. */
  13. protected $dontReport = [
  14. \Illuminate\Auth\AuthenticationException::class,
  15. \Illuminate\Auth\Access\AuthorizationException::class,
  16. \Symfony\Component\HttpKernel\Exception\HttpException::class,
  17. \Illuminate\Database\Eloquent\ModelNotFoundException::class,
  18. \Illuminate\Session\TokenMismatchException::class,
  19. \Illuminate\Validation\ValidationException::class,
  20. ];
  21. /**
  22. * Report or log an exception.
  23. *
  24. * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
  25. *
  26. * @param \Exception $exception
  27. * @return void
  28. */
  29. public function report(Exception $exception)
  30. {
  31. parent::report($exception);
  32. }
  33. /**
  34. * Render an exception into an HTTP response.
  35. *
  36. * @param \Illuminate\Http\Request $request
  37. * @param \Exception $exception
  38. * @return \Illuminate\Http\Response
  39. */
  40. public function render($request, Exception $exception)
  41. {
  42. return parent::render($request, $exception);
  43. }
  44. /**
  45. * Convert an authentication exception into an unauthenticated response.
  46. *
  47. * @param \Illuminate\Http\Request $request
  48. * @param \Illuminate\Auth\AuthenticationException $exception
  49. * @return \Illuminate\Http\Response
  50. */
  51. protected function unauthenticated($request, AuthenticationException $exception)
  52. {
  53. if ($request->expectsJson()) {
  54. return response()->json(['error' => 'Unauthenticated.'], 401);
  55. }
  56. return redirect()->guest(route('login'));
  57. }
  58. }