Skip to content

feat(errors): add cause chaining, 6 typed error classes, and toJSON#83

Merged
zeevdr merged 1 commit into
mainfrom
feat/error-cause-and-typed-classes
May 24, 2026
Merged

feat(errors): add cause chaining, 6 typed error classes, and toJSON#83
zeevdr merged 1 commit into
mainfrom
feat/error-cause-and-typed-classes

Conversation

@zeevdr
Copy link
Copy Markdown
Member

@zeevdr zeevdr commented May 24, 2026

Summary

  • Preserves the original gRPC ServiceError via { cause: err } in mapGrpcError, so stack traces and metadata aren't silently dropped.
  • Adds six missing typed error classes (ResourceExhaustedError, DataLossError, OutOfRangeError, CancelledError, UnimplementedError, DeadlineExceededError) and wires them into the status map and public index.
  • Adds toJSON() on DecreeError so structured loggers (Pino, Winston, etc.) include name, code, and message without custom serializers.

Test plan

  • All 185 existing tests still pass
  • New tests cover each of the six new typed classes (instanceof + code)
  • Cause chaining verified: mapGrpcError(grpcErr).cause === grpcErr for both typed and generic paths
  • toJSON() tests: correct fields on base class and subclasses
  • Biome lint + format pass, tsc --noEmit clean

Closes #52

Pass { cause: err } in mapGrpcError so the original gRPC ServiceError
is preserved in the error chain for logging and debugging.

Add ResourceExhaustedError, DataLossError, OutOfRangeError,
CancelledError, UnimplementedError, and DeadlineExceededError, wiring
each into STATUS_MAP and exporting from src/index.ts.

Add toJSON() on DecreeError so logging frameworks retain name, code,
and message as structured fields on every error subclass.

Expand test/errors.test.ts to cover new typed classes, cause chaining,
and toJSON behavior.

Co-Authored-By: Claude <noreply@anthropic.com>
Closes #52
@zeevdr zeevdr added this to the Beta Readiness milestone May 24, 2026
@zeevdr zeevdr added size: S Quick win — a few hours or less priority: P1 Current milestone work labels May 24, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@zeevdr zeevdr merged commit 626acc0 into main May 24, 2026
14 checks passed
@zeevdr zeevdr deleted the feat/error-cause-and-typed-classes branch May 24, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: P1 Current milestone work size: S Quick win — a few hours or less

Projects

None yet

Development

Successfully merging this pull request may close these issues.

errors.ts: add cause chaining and missing typed classes

1 participant