Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

Handler.php 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php namespace App\Exceptions;
  2. use Exception;
  3. use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
  4. use Symfony\Component\HttpKernel\Exception\HttpException;
  5. class Handler extends ExceptionHandler {
  6. /**
  7. * A list of the exception types that should not be reported.
  8. *
  9. * @var array
  10. */
  11. protected $dontReport = [
  12. 'Symfony\Component\HttpKernel\Exception\HttpException'
  13. ];
  14. /**
  15. * Report or log an exception.
  16. *
  17. * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
  18. *
  19. * @param \Exception $e
  20. * @return void
  21. */
  22. public function report(Exception $e)
  23. {
  24. return parent::report($e);
  25. }
  26. /**
  27. * Render an exception into an HTTP response.
  28. *
  29. * @param \Illuminate\Http\Request $request
  30. * @param \Exception $e
  31. * @return \Illuminate\Http\Response
  32. */
  33. public function render($request, Exception $e)
  34. {
  35. /** @var $message_error : Message error */
  36. $message_error = $e->getMessage();
  37. if ($e instanceof HttpException) {
  38. return response()->json([
  39. 'code' => $e->getStatusCode(),
  40. 'message' => $message_error
  41. ], $e->getStatusCode());
  42. }
  43. return parent::render($request, $e);
  44. }
  45. }