Bourse.Symbol.Error exception (bourse v0.1.0)

Copy Markdown View Source

Error raised when symbol conversion fails.

Provides detailed context about what went wrong, including the symbol, reason, exchange ID, and market type when available.

Summary

Functions

Creates an error for invalid symbol format.

Creates a symbol error with optional symbol, reason, exchange, and market context.

Creates an error for parse failures.

Creates an error for missing pattern configuration.

Creates an error for unknown quote currency.

Creates an error when a reverse conversion rewrote an id without unifying it.

Creates an error for unsupported prefix patterns.

Types

reason()

@type reason() ::
  :invalid_format
  | :pattern_not_found
  | :unknown_quote_currency
  | :parse_failed
  | :unrepresentable_id
  | {:unsupported_prefix, String.t()}

t()

@type t() :: %Bourse.Symbol.Error{
  __exception__: term(),
  exchange_id: String.t() | nil,
  market_type: atom() | nil,
  message: String.t(),
  reason: reason(),
  symbol: String.t() | nil
}

Functions

invalid_format(symbol)

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

Creates an error for invalid symbol format.

new(message, opts \\ [])

@spec new(
  String.t(),
  keyword()
) :: t()

Creates a symbol error with optional symbol, reason, exchange, and market context.

parse_failed(symbol, reason)

@spec parse_failed(String.t(), term()) :: t()

Creates an error for parse failures.

pattern_not_found(symbol, market_type, exchange_id \\ nil)

@spec pattern_not_found(String.t(), atom(), String.t() | nil) :: t()

Creates an error for missing pattern configuration.

unknown_quote_currency(symbol, attempted_split \\ nil)

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

Creates an error for unknown quote currency.

unrepresentable_id(exchange_id, converted, exchange \\ nil, market_type \\ nil)

@spec unrepresentable_id(String.t(), String.t(), String.t() | nil, atom() | nil) ::
  t()

Creates an error when a reverse conversion rewrote an id without unifying it.

Used when a pattern path partially transforms an exchange id (e.g. upcase) but does not produce a unified symbol — returning that intermediate would be a plausible-but-wrong string that resolves to nothing.

unsupported_prefix(symbol, prefix)

@spec unsupported_prefix(String.t(), String.t()) :: t()

Creates an error for unsupported prefix patterns.