Skip to content

fix(errors): carry the whole API error envelope on ZernioApiError - #10

Merged
mikipalet merged 1 commit into
mainfrom
fix/carry-full-error-envelope
Sep 15, 2026
Merged

mikipalet merged 1 commit into
mainfrom
fix/carry-full-error-envelope

Conversation

@mikipalet

Copy link
Copy Markdown
Member

Why

Reported by an integrator, and first raised 57 releases ago (0.2.727, now 0.2.784).

parseApiError built ZernioApiError from body.error, body.code and body.details only. The canonical ErrorResponse has seven fields, so type, param, platform and platformError were dropped on every endpoint, not just sends.

For Meta this breaks error handling outright: a closed messaging window and a blocked recipient both arrive as code platform_api_error, and platformError.subcode is the only thing that tells them apart. That was exactly the field being discarded, so callers could see that Meta refused but never why.

What

  • ZernioApiError exposes type, param, platform and platformError, plus body carrying the parsed response verbatim so nothing the API adds later is lost again.
  • RateLimitError and ValidationError keep the API's own code and details rather than overwriting them with a generic value. A Google Ads quota 429 (code: rate_limited, details.quotaExhausted, details.quotaScope) now stays distinguishable from a Zernio rate limit.
  • No breaking change: every existing field keeps its meaning, the new ones are additive.

206 tests, typecheck and lint all pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Kq8TeJSGdkrGv4evwMBfJ8

parseApiError built the error from body.error, body.code and body.details
only, so of the seven canonical ErrorResponse fields it surfaced three. type,
param, platform and platformError were dropped on EVERY endpoint.

For Meta sends that is fatal to error handling: a closed messaging window and a
blocked recipient both arrive as code platform_api_error, and only
platformError.subcode separates them, which was the field being dropped.

- ZernioApiError exposes type, param, platform and platformError, plus `body`
  with the parsed response verbatim for anything not modelled
- RateLimitError and ValidationError keep the API's own code and details
  instead of overwriting them with a generic one, so a Google Ads quota 429
  stays distinguishable from a Zernio rate limit
- reported by an integrator, first raised 57 releases ago

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kq8TeJSGdkrGv4evwMBfJ8
@mikipalet
mikipalet merged commit 6f6cfaf into main Sep 15, 2026
2 checks passed
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