Skip to content

Add APIError class with HTTP error parsing#13

Merged
parthban-db merged 3 commits into
mainfrom
parthban-db/stack/port-api-error
Feb 27, 2026
Merged

Add APIError class with HTTP error parsing#13
parthban-db merged 3 commits into
mainfrom
parthban-db/stack/port-api-error

Conversation

@parthban-db
Copy link
Copy Markdown
Contributor

@parthban-db parthban-db commented Feb 26, 2026

🥞 Stacked PR

Use this link to review incremental changes.


What changes are proposed in this pull request?

Add the core APIError class and fromHttpError factory function, ported from the Go SDK's apierr/apierr.go. This is the main error type that will be returned by all Databricks API calls.

  • APIError — a transport-agnostic error class extending Error with code, message, details, and HTTP metadata (status code, headers, body).
  • fromHttpError(statusCode, header, body) — parses HTTP error responses into APIError, handling standard, legacy (API 1.2), and SCIM error formats. Returns undefined for 2xx status codes.
  • toCode(httpCode) — maps HTTP status codes to canonical Code values (e.g. 404 → NOT_FOUND, 429 → RESOURCE_EXHAUSTED).
  • Uses a Zod schema for lenient JSON body parsing, supporting error_code as string or integer, multiple message fields (message, error, detail, scimType), and structured error details.

How is this tested?

Unit tests.

@parthban-db parthban-db mentioned this pull request Feb 27, 2026
@parthban-db parthban-db added this pull request to the merge queue Feb 27, 2026
Merged via the queue into main with commit 9a26ef9 Feb 27, 2026
12 checks passed
@parthban-db parthban-db deleted the parthban-db/stack/port-api-error branch May 12, 2026 15:37
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.

2 participants