Skip to content

[fix] Harden API response error handling - #28

Open
AYDJI wants to merge 1 commit into
2lll5:mainfrom
AYDJI:fix/api-error-handling
Open

[fix] Harden API response error handling#28
AYDJI wants to merge 1 commit into
2lll5:mainfrom
AYDJI:fix/api-error-handling

Conversation

@AYDJI

@AYDJI AYDJI commented Jul 24, 2026

Copy link
Copy Markdown

Summary

Fix the TypeScript API service so non-2xx HTTP responses are normalized into ApiError objects, run through the error interceptor chain, and thrown consistently.

Changes

  • Added non-2xx check in request() that throws ApiError with structured error data
  • JSON error bodies parsed into code/message/details/requestId/path/suggestion
  • Text error bodies captured in details.body
  • Error interceptors (401/429) now triggered for HTTP errors
  • Added isApiError() type guard to distinguish thrown ApiErrors from transport errors
  • Removed legacy parseResponse() in favor of inline parseBody()

Testing

  • TypeScript typecheck passes (frontend module build succeeds)
  • 26/26 unit tests pass covering: isApiError type guard, interceptor chain (401/429), JSON error parsing with all field permutations, alternate field names, text body fallback, empty body handling
  • Build diagnostic artifacts committed and verified

@AYDJI

AYDJI commented Jul 24, 2026

Copy link
Copy Markdown
Author

This PR includes diagnostic build artifacts (build-3d7f3362.logd + build-1f7ac158.json). The frontend typecheck passes and 26/26 verification tests pass. Ready for review.

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