getStatusCode(); $errorMessage = Response::$statusTexts[$errorCode]; return $this->errorResponse($errorMessage, $errorCode); } if ($exception instanceof ModelNotFoundException) { $model = strtolower(class_basename($exception->getModel())); return $this->errorResponse( "Does not exist any instance of {$model} with a given id", Response::HTTP_NOT_FOUND); } if ($exception instanceof AuthorizationException) { return $this->errorResponse( $exception->getMessage(), Response::HTTP_FORBIDDEN); } if ($exception instanceof AuthenticationException) { return $this->errorResponse( $exception->getMessage(), Response::HTTP_UNAUTHORIZED); } if ($exception instanceof ValidationException) { $errors = $exception->validator->errors()->getMessages(); return $this->errorResponse( $errors, Response::HTTP_UNPROCESSABLE_ENTITY); } if ($exception instanceof ClientException) { $errorMessage = $exception->getResponse()->getBody(); $errorCode = $exception->getCode(); return $this->errorMessage($errorMessage, $errorCode); } if (env('APP_DEBUG', false)) { return parent::render($request, $exception); } return $this->errorResponse( "Unexpected error. Try later!", Response::HTTP_INTERNAL_SERVER_ERROR); } }