DSpace.API.Error exception (dspace_ex v0.1.0-alpha2)

Copy Markdown View Source

Represents an API Error.

Summary

Functions

Builds an error from a response structure based on the HTTP status code.

Types

error_type()

@type error_type() ::
  :bad_request
  | :unauthorized
  | :forbidden
  | :not_found
  | :method_not_allowed
  | :unprocessable_entity
  | :too_many_requests
  | :server_error
  | :api_csrf_invalid
  | :api_unexpected_response
  | :api_unexpected_payload
  | :api_unexpected_client_error

t()

@type t() :: %DSpace.API.Error{
  __exception__: term(),
  message: binary(),
  request_url: URI.t(),
  response: DSpace.API.HTTP.Response.t(),
  status: non_neg_integer(),
  type: error_type()
}

Functions

from_response(response)

@spec from_response(DSpace.API.HTTP.Response.t()) :: t()

Builds an error from a response structure based on the HTTP status code.

response_validation_error(response, message \\ "API response data invalid for expected schema.")

@spec response_validation_error(DSpace.API.HTTP.Response.t(), binary()) :: t()

Builds a validation error from a response structure.