Structured error for :auth_failed, :http_error, and unparsed :request_failed
outcomes.
Safaricom JSON error envelopes are parsed into request_id, error_code, and
error_message. Non-JSON bodies are summarized without including the raw
response in inspect/1, so callers can log inspect(error) safely at :info
or above. Use raw_body/1 when the unparsed body is needed for debugging.
Accepted JSON keys
Fields are read from the first matching key in each group:
request_id—"requestId","requestid"error_code—"errorCode","error"(OAuth-style)error_message—"errorMessage","error_description"(OAuth-style)
Only non-empty binary values are accepted; falsy values (false, 0, "") are
treated as absent. A decoded JSON object must contain at least one of the keys
above or it is treated as an unrecognized error body.
Summary
Functions
Returns the unparsed response body when JSON decoding failed or the payload was not a recognized error envelope.