Skip to content

feat: implement structured error handling#50

Merged
besart-finsweet merged 3 commits intomasterfrom
feat/structured-errors
Apr 22, 2026
Merged

feat: implement structured error handling#50
besart-finsweet merged 3 commits intomasterfrom
feat/structured-errors

Conversation

@besart-finsweet
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a structured, SDK-like error model across the Firestore REST client so consumers can reliably branch on stable error codes instead of parsing error messages.

Changes:

  • Add FirestoreError / FirestoreErrorCode, plus helpers (throw_if_error, safe_fetch) to normalize REST + network failures.
  • Update core operations (get/create/set/update/query/batch/remove) to use the new structured error handling.
  • Document the new error contract and add unit tests around the new behavior.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/error.ts Adds FirestoreError, status-to-code mapping, and helpers for consistent error throwing/wrapping.
src/error.test.ts Adds tests asserting errors surface as FirestoreError with stable codes.
src/get.ts Switches to safe_fetch + throw_if_error for structured errors.
src/create.ts Switches to safe_fetch + throw_if_error for structured errors.
src/set.ts Switches to safe_fetch + throw_if_error for structured errors.
src/update.ts Switches to safe_fetch + throw_if_error for structured errors.
src/query.ts Switches to safe_fetch + throw_if_error, with explicit union typing for error responses.
src/batch.ts Switches to safe_fetch + throw_if_error, returning typed commit response on success.
src/remove.ts Uses safe_fetch and attempts to throw structured errors on non-OK responses.
src/index.ts Re-exports FirestoreError / FirestoreErrorCode as part of the public API.
README.md Documents the new error handling model and enumerates error codes/fields.
.changeset/structured-firestore-errors.md Declares a minor release and describes the new error behavior/fields.
.vscode/settings.json Adds “Firestore” to cSpell dictionary.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/remove.ts Outdated
Comment thread src/error.ts
alexiglesias93
alexiglesias93 previously approved these changes Apr 22, 2026
Copy link
Copy Markdown
Member

@alexiglesias93 alexiglesias93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md Outdated
Comment thread .changeset/structured-firestore-errors.md
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@besart-finsweet besart-finsweet merged commit 71fa433 into master Apr 22, 2026
3 checks passed
@besart-finsweet besart-finsweet deleted the feat/structured-errors branch April 22, 2026 10:58
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.

3 participants