Handler.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace App\Exceptions;
  3. use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
  4. use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
  5. use Throwable;
  6. class Handler extends ExceptionHandler
  7. {
  8. /**
  9. * A list of the exception types that are not reported.
  10. *
  11. * @var array<int, class-string<Throwable>>
  12. */
  13. protected $dontReport = [
  14. //
  15. ];
  16. /**
  17. * A list of the inputs that are never flashed for validation exceptions.
  18. *
  19. * @var array<int, string>
  20. */
  21. protected $dontFlash = [
  22. 'current_password',
  23. 'password',
  24. 'password_confirmation',
  25. ];
  26. /**
  27. * Register the exception handling callbacks for the application.
  28. *
  29. * @return void
  30. */
  31. public function register()
  32. {
  33. $this->reportable(function (Throwable $e) {
  34. //
  35. });
  36. $this->renderable(function (MethodNotAllowedHttpException $e, $request){
  37. $respuesta = json_encode([
  38. "error" => true,
  39. "msg" => "ERR_GLB_USU000: Método no soportado.",
  40. "response" => []
  41. ]);
  42. return response($respuesta, 405)->header('Content-Type', 'application/json');
  43. });
  44. }
  45. }