open_payments/error

Types

The error codes defined by the Open Payments auth server. Codes not in this list, such as the free-form codes returned by resource servers, are kept as OtherErrorCode.

pub type ErrorCode {
  InvalidClient
  InvalidRequest
  RequestDenied
  TooFast
  InvalidContinuation
  InvalidRotation
  OtherErrorCode(String)
}

Constructors

  • InvalidClient

    The client is unknown to the auth server, or its signature could not be verified.

  • InvalidRequest

    The request was missing a required parameter or was otherwise malformed.

  • RequestDenied

    The request was denied, e.g. because the user rejected the grant.

  • TooFast

    The client polled a continuation before its wait period elapsed and should back off before trying again.

  • InvalidContinuation

    The continuation URI or access token is invalid, or the grant can no longer be continued.

  • InvalidRotation

    The access token could not be rotated.

  • OtherErrorCode(String)

Errors that can occur while using the Open Payments SDK. Every public function that talks to a server or reads key material returns Result(_, OpenPaymentsError), so callers can match on the failure kind instead of parsing a message.

pub type OpenPaymentsError {
  TransportError(String)
  ApiError(
    status: Int,
    body: String,
    error: option.Option(ServerError),
    as_uri: option.Option(String),
  )
  DecodeError(String)
  KeyError(String)
  ValidationError(String)
}

Constructors

  • TransportError(String)

    The request could not be sent: the URL was invalid, the request could not be signed, or the underlying HTTP client failed to reach the server.

  • ApiError(
      status: Int,
      body: String,
      error: option.Option(ServerError),
      as_uri: option.Option(String),
    )

    The server responded, but with a non-success status. body is the raw response body. error is the machine-readable error parsed from it, when the body carries one. as_uri is the auth server named in a WWW-Authenticate: GNAP as_uri=... header, which resource servers send on a 401 to say where an access token can be requested.

  • DecodeError(String)

    The response body was not valid JSON, or didn’t match the shape expected for this operation.

  • KeyError(String)

    The private key file could not be read, or didn’t contain a valid PKCS#8 PEM-encoded Ed25519 private key.

  • ValidationError(String)

    The options passed in break a rule of the Open Payments spec, so the request was not sent.

The error object returned in the body of a failed request. See https://openpayments.dev/apis/auth-server/operations/post-request/ and https://openpayments.dev/apis/resource-server/operations/create-incoming-payment/

pub type ServerError {
  ServerError(
    code: ErrorCode,
    description: option.Option(String),
    details: option.Option(dynamic.Dynamic),
  )
}

Constructors

✨ Search Document