coinglecko/error

Error types for the CoinGecko API client.

Types

All errors that can occur when making API calls.

pub type CoinGeckoError {
  HttpError(message: String)
  ApiError(
    status: Int,
    body: String,
    error_message: option.Option(String),
  )
  DecodeError(error: json.DecodeError)
  RequestError(message: String)
}

Constructors

  • HttpError(message: String)

    HTTP request failed (network error, DNS failure, timeout, etc.)

  • ApiError(
      status: Int,
      body: String,
      error_message: option.Option(String),
    )

    Server returned a non-200 status code.

  • DecodeError(error: json.DecodeError)

    Failed to decode JSON response body.

  • RequestError(message: String)

    Failed to construct the HTTP request (e.g., invalid URL).

Values

pub fn parse_error_body(body: String) -> option.Option(String)

Try to extract an error message from a CoinGecko error response body. CoinGecko returns {"error": "message"} for some errors, and HTML for others.

pub fn to_string(error: CoinGeckoError) -> String

Convert an error to a human-readable string.

Search Document