pify/error

One error type for the whole library.

Types

pub type ShopifyError {
  ShopifyErrorApi(message: String, code: option.Option(String))
  ShopifyErrorAuthentication
  ShopifyErrorForbidden(message: String)
  ShopifyErrorNotFound
  ShopifyErrorShopUnavailable(status: Int)
  ShopifyErrorThrottled(retry_after_ms: option.Option(Int))
  ShopifyErrorServer(status: Int)
  ShopifyErrorNetwork(message: String)
  ShopifyErrorDecode(errors: List(decode.DecodeError))
  ShopifyErrorMalformedJson(cause: json.DecodeError)
  ShopifyErrorUserErrors(errors: List(UserError))
  ShopifyErrorSignatureInvalid
  ShopifyErrorSignatureMissing
  ShopifyErrorTopicBodyMismatch(topic: String)
  ShopifyErrorTopicUnsupported(topic: String)
}

Constructors

  • ShopifyErrorApi(message: String, code: option.Option(String))

    Shopify answered with a GraphQL error that no other variant names, or with an HTTP status outside the mapped set.

  • ShopifyErrorAuthentication

    HTTP 401, or a token request refused with 400 or 401. The token is wrong or expired.

  • ShopifyErrorForbidden(message: String)

    HTTP 403, or ACCESS_DENIED in a 200. The token lacks a scope.

  • ShopifyErrorNotFound

    HTTP 404: the shop domain or the version path is wrong.

  • ShopifyErrorShopUnavailable(status: Int)

    HTTP 402 (the shop is frozen for payment) or 423 (the shop is locked).

  • ShopifyErrorThrottled(retry_after_ms: option.Option(Int))

    HTTP 429, or THROTTLED in a 200. Wait retry_after_ms when known.

  • ShopifyErrorServer(status: Int)
  • ShopifyErrorNetwork(message: String)

    The request never got an answer, including a call the effect runner stopped at Client.timeout_ms.

  • ShopifyErrorDecode(errors: List(decode.DecodeError))

    The body is JSON, but not the shape the decoder expects.

  • ShopifyErrorMalformedJson(cause: json.DecodeError)

    The body is not JSON.

  • ShopifyErrorUserErrors(errors: List(UserError))

    A mutation ran and refused the input.

  • ShopifyErrorSignatureInvalid
  • ShopifyErrorSignatureMissing
  • ShopifyErrorTopicBodyMismatch(topic: String)

    The unsigned topic header does not fit the signed body’s shape.

  • ShopifyErrorTopicUnsupported(topic: String)

    The topic has no subscription enum, so it cannot be subscribed to.

One entry of a mutation’s userErrors. field is the input path.

pub type UserError {
  UserError(
    field: List(String),
    message: String,
    code: option.Option(String),
  )
}

Constructors

  • UserError(
      field: List(String),
      message: String,
      code: option.Option(String),
    )

Values

pub fn from_json(json_error: json.DecodeError) -> ShopifyError

The one place a json.DecodeError becomes a ShopifyError: a shape mismatch keeps its field errors, anything else keeps the parser’s cause.

pub fn to_string(error: ShopifyError) -> String

A line for logs. It carries no token, secret or body.

✨ Search Document