crux_rest v0.1.7 Crux.Rest.ApiError exception View Source

Represents a Discord API error.

Raised or returned whenever the api responded with a non 2xx status code

Link to this section Summary

Types

t()
PropertyDescriptionExample(s)
status_codeHTTP status code400, 404, 403
codeSee Discord’s JSON Error Codes10006, 90001
messageMessage describing the errorUnknown Invite
pathPath of the request/invites/broken

Functions

Default implementation only providing a message for raise/2

Creates a full Crux.Rest.ApiError struct, returned / raised by all Crux.Rest functions in case of an API error

Link to this section Types

Link to this type t() View Source (since 0.1.0)
t() :: %{
  status_code: integer(),
  code: integer() | nil,
  message: String.t(),
  path: String.t(),
  method: String.t()
}
PropertyDescriptionExample(s)
status_codeHTTP status code400, 404, 403
codeSee Discord’s JSON Error Codes10006, 90001
messageMessage describing the errorUnknown Invite
pathPath of the request/invites/broken

Link to this section Functions

Link to this function exception(msg) View Source (since 0.1.0)
exception(message :: String.t()) :: Crux.Rest.ApiError.t()

Default implementation only providing a message for raise/2

Link to this function exception(error, status_code, path, method) View Source (since 0.1.0)
exception(
  error :: map(),
  status_code :: pos_integer(),
  path :: String.t(),
  method :: String.t()
) :: Crux.Rest.ApiError.t()

Creates a full Crux.Rest.ApiError struct, returned / raised by all Crux.Rest functions in case of an API error.