Skip to content

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

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

Surface API error messages and standardize HTTP status fallback messages#93
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

  • API-message extraction now applies to every error status (was limited to 400/401/402/403/413/422/429); added 408/502 with new RequestTimeoutError/BadGatewayError.
  • Unknown non-200 statuses previously produced no error at all; they now raise SmartyException with the standard unexpected-status 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