Error struct and handling for Tink.
All API errors are wrapped in this struct for consistent error handling.
Error Types
:api_error- Tink API returned an error response:network_error- Network/connection error:timeout- Request timed out:authentication_error- Auth failure:rate_limit_error- Rate limit exceeded:validation_error- Invalid parameters:decode_error- Failed to decode response:market_mismatch- Provider not available in requested market:unknown- Unknown error
Examples
case Tink.Accounts.list(client) do
{:ok, accounts} ->
# Success
{:error, %Tink.Error{type: :rate_limit_error}} ->
# Handle rate limit
{:error, %Tink.Error{status: 401}} ->
# Handle unauthorized
{:error, error} ->
IO.inspect(error)
end
Summary
Functions
Returns a human-readable error message.
Creates an error from an HTTP client error.
Creates an error from an HTTP response.
Creates a new error struct.
Checks if an error is retryable.
Types
@type error_type() ::
:api_error
| :network_error
| :timeout
| :authentication_error
| :rate_limit_error
| :validation_error
| :decode_error
| :market_mismatch
| :unknown
Functions
Returns a human-readable error message.
Examples
iex> error = Tink.Error.from_response(429, %{"errorMessage" => "Rate limit exceeded"})
iex> Tink.Error.format(error)
"[429] Rate limit exceeded (RATE_LIMIT_ERROR)"
Creates an error from an HTTP client error.
Examples
iex> Tink.Error.from_http_error(%{type: :timeout, reason: "Request timed out"})
%Tink.Error{type: :timeout, message: "Request timed out"}
Creates an error from an HTTP response.
Examples
iex> Tink.Error.from_response(400, %{"errorCode" => "INVALID_REQUEST"})
%Tink.Error{type: :api_error, status: 400, error_code: "INVALID_REQUEST"}
Creates a new error struct.
Examples
iex> Tink.Error.new(type: :network_error, message: "Connection failed")
%Tink.Error{type: :network_error, message: "Connection failed"}
Checks if an error is retryable.
Examples
iex> error = %Tink.Error{type: :network_error, message: ""}
iex> Tink.Error.retryable?(error)
true
iex> error = %Tink.Error{type: :validation_error, message: ""}
iex> Tink.Error.retryable?(error)
false