Skip to content

Surface API error messages and standardize HTTP status fallback messages#85

Open
CarterSmarty wants to merge 1 commit into
masterfrom
carter/shared-errors
Open

Surface API error messages and standardize HTTP status fallback messages#85
CarterSmarty wants to merge 1 commit into
masterfrom
carter/shared-errors

Conversation

@CarterSmarty

@CarterSmarty CarterSmarty commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the standard error message scheme shared across all Smarty SDKs: every HTTP error status now surfaces the message from the API's JSON error body ({"errors":[{"message":"..."}]}) when one is present, and falls back to the standard per-status message list otherwise (304, 400, 401, 402, 403, 408, 413, 422, 429, 500, 502, 503, 504, plus an "unexpected status code" default).

In this SDK

  • Added 403/408/502/504 and unknown-status handling (these previously produced no error at all); new RequestTimeoutError/BadGatewayError classes.
  • Malformed JSON error bodies no longer raise JSON::ParserError; they fall back to the standard message.
  • Constants standardized (old ones contained literal embedded newlines mid-message).

Validation

  • Unit tests cover every handled status: API message preferred, exact standard fallback on empty/malformed/unusable bodies, unknown status codes, and unchanged 304/ETag behavior.
  • Verified against the live API with real credentials: 400 (missing street), 401 (bad credentials), 404 (unexpected-status path), and 422 (out-of-range latitude) each surfaced the server's own message through this SDK's full client chain.

Related PRs (same change in every SDK)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant