libduvet/error

Types

pub type ApiFailure {
  ApiFailure(
    action: String,
    status_code: Int,
    body: option.Option(String),
  )
}

Constructors

  • ApiFailure(
      action: String,
      status_code: Int,
      body: option.Option(String),
    )
pub type AuthFailure {
  AuthFailure(
    action: String,
    status_code: Int,
    body: option.Option(String),
  )
}

Constructors

  • AuthFailure(
      action: String,
      status_code: Int,
      body: option.Option(String),
    )

Everything a request can fail with. Dart’s package throws exceptions; here every call answers a Result, and the failure carries what the exception carried.

pub type DuvetError {
  ApiError(failure: ApiFailure)
  AuthError(failure: AuthFailure)
  RequestTimeout(method: String, path: String, timeout_ms: Int)
  RequestAborted
  NetworkError(reason: String)
  MalformedMessage(cause: String)
  InvalidArgument(message: String)
}

Constructors

  • ApiError(failure: ApiFailure)

    The API answered 2xx-but-an-error, or any status but 401 and 403.

  • AuthError(failure: AuthFailure)

    The API answered 401 or 403: the session is missing, expired or not allowed.

  • RequestTimeout(method: String, path: String, timeout_ms: Int)

    Nothing moved for the request’s timeout.

  • RequestAborted

    The caller’s abort trigger completed first.

  • NetworkError(reason: String)

    The connection failed or was closed.

  • MalformedMessage(cause: String)

    The API or the gateway sent something this package couldn’t read.

  • InvalidArgument(message: String)

    The arguments themselves are wrong, and nothing was sent.

Values

pub fn api(
  action: String,
  status_code: Int,
  body: String,
) -> DuvetError
pub fn auth(
  action: String,
  status_code: Int,
  body: String,
) -> DuvetError
pub fn from_send_error(error: send.SendError) -> DuvetError
pub fn is_aborted(error: DuvetError) -> Bool
pub fn is_timeout(error: DuvetError) -> Bool
pub fn message(error: DuvetError) -> String

The failure’s message, as the Dart exception’s message reads.

pub fn status_code(error: DuvetError) -> option.Option(Int)
pub fn to_string(error: DuvetError) -> String

The failure’s text, as the Dart exception’s toString reads (for logs).

✨ Search Document