DatagroutConduit.Error exception (DataGrout Conduit v0.6.0)

Copy Markdown View Source

Structured error types for the Conduit SDK.

All transports and client operations return {:error, %DatagroutConduit.Error{}} for typed error conditions (rate limit, auth). Other errors may still be {:error, term}.

Example

case DatagroutConduit.Client.list_tools(client) do
  {:ok, tools} -> tools
  {:error, %DatagroutConduit.Error{type: :rate_limit, retry_after: t}} ->
    Process.sleep(:timer.seconds(String.to_integer(t || "5")))
  {:error, %DatagroutConduit.Error{type: :auth, message: msg}} ->
    raise "Auth failure: #{msg}"
  {:error, reason} ->
    raise "Unexpected error: #{inspect(reason)}"
end

Summary

Functions

Returns an authentication error (HTTP 401 or token rejection).

Returns a configuration error raised during client setup.

Returns a network-layer error (connection refused, DNS failure, etc.).

Returns an error indicating the client has not been initialized.

Returns a rate-limit error with an optional Retry-After value from the server.

Returns a server-side error with an HTTP status code.

Types

error_type()

@type error_type() ::
  :not_initialized
  | :rate_limit
  | :auth
  | :network
  | :protocol
  | :timeout
  | :invalid_config
  | :server
  | :other

t()

@type t() :: %DatagroutConduit.Error{
  __exception__: true,
  code: integer() | nil,
  message: String.t(),
  retry_after: String.t() | nil,
  type: error_type()
}

Functions

auth(msg)

@spec auth(String.t()) :: t()

Returns an authentication error (HTTP 401 or token rejection).

invalid_config(msg)

@spec invalid_config(String.t()) :: t()

Returns a configuration error raised during client setup.

network(msg)

@spec network(String.t()) :: t()

Returns a network-layer error (connection refused, DNS failure, etc.).

not_initialized(msg \\ "Client not initialized")

@spec not_initialized(String.t()) :: t()

Returns an error indicating the client has not been initialized.

Used when a call is attempted before start_link/1 succeeds.

rate_limit(msg, retry_after \\ nil)

@spec rate_limit(String.t(), String.t() | nil) :: t()

Returns a rate-limit error with an optional Retry-After value from the server.

The retry_after value, when present, is the raw string value of the Retry-After HTTP response header (e.g. "30" for 30 seconds).

server(msg, code)

@spec server(String.t(), integer()) :: t()

Returns a server-side error with an HTTP status code.