Geofox.Utils.ErrorHandler (geofox_ex v0.1.1)

View Source

Error handling utilities for Geofox API responses.

Summary

Functions

Check an API response for error codes and return a normalized result.

Extract data from a successful API response, raising on errors.

Handle Tesla/HTTP client responses (used internally by Client module).

Functions

check_response(response)

@spec check_response(map()) :: {:ok, map()} | {:error, term()}

Check an API response for error codes and return a normalized result.

Examples

{:ok, data} = response |> Geofox.Utils.ErrorHandler.check_response()
{:error, reason} = response |> Geofox.Utils.ErrorHandler.check_response()

extract_data!(response)

@spec extract_data!(map()) :: map()

Extract data from a successful API response, raising on errors.

Useful for pipeline operations where you want to fail fast on API errors.

handle_response(response)

@spec handle_response({:ok, map()} | {:error, term()}) ::
  {:ok, map()} | {:error, term()}

Handle Tesla/HTTP client responses (used internally by Client module).