Bourse.HTTP.Errors (bourse v0.1.0)

Copy Markdown View Source

Classifies HTTP and body-level exchange responses into Bourse.Error structs.

Extracted from Bourse.HTTP so the transport layer can stay focused on request execution while error taxonomy (status maps, body sentinels, HTML/geo-block detection) lives in one place. Behavior-preserving delegation only — the public HTTP API is unchanged.

Summary

Types

Normalized success response map

HTTP response headers as returned by Req

Functions

Classifies an HTTP response into {:ok, response} or {:error, Error.t()}.

Types

response()

@type response() :: %{status: integer(), headers: response_headers(), body: term()}

Normalized success response map

response_headers()

@type response_headers() :: %{optional(String.t()) => [String.t()]}

HTTP response headers as returned by Req

Functions

classify_response(method, status, headers, body, exchange)

@spec classify_response(
  atom(),
  integer(),
  response_headers(),
  term(),
  Bourse.Exchange.t()
) ::
  {:ok, response()} | {:error, Bourse.Error.t()}

Classifies an HTTP response into {:ok, response} or {:error, Error.t()}.

Handles 2xx body-level errors, non-2xx status normalization, HTML/geo-block and Cloudflare challenge detection. Empty 2xx bodies are successful responses.