Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typed Errors #21

Merged
merged 7 commits into from
Feb 26, 2024
Merged

Typed Errors #21

merged 7 commits into from
Feb 26, 2024

Conversation

penx
Copy link
Contributor

@penx penx commented Oct 24, 2023

This PR adds descriptively typed errors to handle various cases when using the SDK. These errors are grouped into two classes:

  • Response errors: These are thrown when an error response is returned from the API (see error-response.ts). Note that these error values originate from the OpenAPI spec, and will change with it.
  • Internal errors: These are thrown when a runtime exception happens client-side. The distinct variants for these are determined by different unhappy paths in the SDK itself.

Tests have been added for the Batch client for both types of errors, but more testing could be done to ensure every type of response error is handled correctly.

TODOS:

  • Tests for the Realtime client still need to be added
  • Need to decide how we want to handle version drift for error types
  • Tests for unsupported environments
  • Maybe some code examples for how to make best use of these error types

src/batch/client.ts Outdated Show resolved Hide resolved
src/realtime/extension.ts Outdated Show resolved Hide resolved
src/realtime/handlers.ts Outdated Show resolved Hide resolved
src/utils/errors.ts Outdated Show resolved Hide resolved
src/utils/errors.ts Outdated Show resolved Hide resolved
src/realtime/handlers.ts Outdated Show resolved Hide resolved
@mnemitz mnemitz marked this pull request as ready for review February 9, 2024 11:41
@mnemitz mnemitz changed the title Typed Errors (draft) Typed Errors Feb 9, 2024
@mnemitz mnemitz merged commit 4984cc8 into main Feb 26, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants