json(['message' => 'Você não tem permissão para realizar esta ação.'], Response::HTTP_FORBIDDEN); } if ($e instanceof ModelNotFoundException) { return response()->json(['error' => 'Registro não encontrado.'], Response::HTTP_NOT_FOUND); } if ($e instanceof QueryException) { //return response()->json(['error' => 'Definir uma mensagem para QueryException.'], Response::HTTP_NOT_FOUND); } if ($e instanceof UnauthorizedHttpException) { return response()->json(['error' => 'Não Autenticado.'], Response::HTTP_UNAUTHORIZED); } if ($e instanceof ValidationException) { return response()->json($e->errors(), Response::HTTP_UNPROCESSABLE_ENTITY); } return parent::render($request, $e); } /** * Register the exception handling callbacks for the application. * * @return void */ public function register() { $this->reportable(function (Throwable $e) { //TODO: Verificar se precisa implementar algo aqui }); } }