Skip to content

feat: custom error types for better error handling#19

Merged
satoshai-dev merged 3 commits intomainfrom
feat/custom-error-types
Feb 26, 2026
Merged

feat: custom error types for better error handling#19
satoshai-dev merged 3 commits intomainfrom
feat/custom-error-types

Conversation

@satoshai-dev
Copy link
Copy Markdown
Owner

Summary

  • Add typed error classes (NetworkError, FeeEstimationError, BroadcastError, ConfirmationError, UserRejectionError, ConfigurationError) extending a base PlaystacksError
  • Replace all generic throw new Error(...) calls with specific error types including relevant context (status codes, txids, URLs)
  • Export all error classes from the public API so users can catch specific failure modes

Test plan

  • Unit tests for all error types (construction, instanceof checks, context fields)
  • Existing tests pass with new error types
  • Typecheck passes
  • Lint passes

Closes #13

🤖 Generated with Claude Code

satoshai-dev and others added 3 commits February 26, 2026 12:47
Replace generic Error throws with typed error classes (NetworkError,
FeeEstimationError, BroadcastError, ConfirmationError, ConfigurationError,
UserRejectionError) so users can catch specific failure modes programmatically.

Closes #13

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
All custom error subclasses now accept an optional ErrorOptions
parameter and forward it to the base class, enabling error cause
chaining via `new NetworkError('msg', 500, url, body, { cause })`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@satoshai-dev satoshai-dev merged commit e3277ee into main Feb 26, 2026
1 check 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.

improvement: custom error types for better error handling

1 participant