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

Convert all errors in @solana/rpc-subscriptions-* to coded exceptions #2236

Conversation

steveluscher
Copy link
Collaborator

No description provided.

@steveluscher
Copy link
Collaborator Author

steveluscher commented Mar 2, 2024

// TODO: Coded error.
throw new Error('WebSocket connection closed', { cause: e });
throw new SolanaError(SOLANA_ERROR__RPC_WEBSOCKET_TRANSPORT_CONNECTION_CLOSED, {
cause: e,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the reason for #2235.

Comment on lines 62 to 64
export const SOLANA_ERROR__RPC_WEBSOCKET_TRANSPORT_CLOSED_BEFORE_MESSAGE_BUFFERED = 56 as const;
export const SOLANA_ERROR__RPC_WEBSOCKET_TRANSPORT_CONNECTION_CLOSED = 57 as const;
export const SOLANA_ERROR__RPC_WEBSOCKET_TRANSPORT_FAILED_TO_CONNECT = 58 as const;
Copy link
Collaborator

Choose a reason for hiding this comment

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

How would you feel about prefixing RPC Subscriptions errors with RPC_SUBSCRIPTIONS and following the same convention as RPC_TRANSPORT_HTTP — i.e. the concrete name of the transport come after the abstract name of the interface. Something like:

// Before.
SOLANA_ERROR__RPC_WEBSOCKET_TRANSPORT_CLOSED_BEFORE_MESSAGE_BUFFERED
SOLANA_ERROR__RPC_WEBSOCKET_TRANSPORT_CONNECTION_CLOSED
SOLANA_ERROR__RPC_WEBSOCKET_TRANSPORT_FAILED_TO_CONNECT
SOLANA_ERROR__SUBSCRIPTION_EXPECTED_SERVER_SUBSCRIPTION_ID
SOLANA_ERROR__SUBSCRIPTION_CANNOT_CREATE_SUBSCRIPTION_REQUEST

// After.
SOLANA_ERROR__RPC_SUBSCRIPTIONS_TRANSPORT_WEBSOCKET_CLOSED_BEFORE_MESSAGE_BUFFERED
SOLANA_ERROR__RPC_SUBSCRIPTIONS_TRANSPORT_WEBSOCKET_CONNECTION_CLOSED
SOLANA_ERROR__RPC_SUBSCRIPTIONS_TRANSPORT_WEBSOCKET_FAILED_TO_CONNECT
SOLANA_ERROR__RPC_SUBSCRIPTIONS_EXPECTED_SERVER_SUBSCRIPTION_ID
SOLANA_ERROR__RPC_SUBSCRIPTIONS_CANNOT_CREATE_SUBSCRIPTION_REQUEST

I also think the first three should probably live under the subscription-related error codes. Unless I'm missing something.

@steveluscher steveluscher force-pushed the 03-02-_SolanaError_now_supports_the_cause_property branch from e969a10 to 8516be1 Compare March 4, 2024 03:01
@steveluscher steveluscher force-pushed the 03-01-Convert_all_errors_in_solana/rpc-subscriptions-_to_coded_exceptions branch from 041950e to 72dde8f Compare March 4, 2024 03:01
@steveluscher
Copy link
Collaborator Author

steveluscher commented Mar 4, 2024

Merge activity

  • Mar 3, 7:02 PM PST: @steveluscher started a stack merge that includes this pull request via Graphite.
  • Mar 3, 7:03 PM PST: Graphite rebased this pull request as part of a merge.
  • Mar 3, 7:04 PM PST: @steveluscher merged this pull request with Graphite.

Base automatically changed from 03-02-_SolanaError_now_supports_the_cause_property to master March 4, 2024 03:02
@steveluscher steveluscher force-pushed the 03-01-Convert_all_errors_in_solana/rpc-subscriptions-_to_coded_exceptions branch from 72dde8f to 70cdcb5 Compare March 4, 2024 03:03
@steveluscher steveluscher merged commit cf9c20c into master Mar 4, 2024
5 of 7 checks passed
@steveluscher steveluscher deleted the 03-01-Convert_all_errors_in_solana/rpc-subscriptions-_to_coded_exceptions branch March 4, 2024 03:04
steveluscher added a commit that referenced this pull request Mar 4, 2024
steveluscher added a commit that referenced this pull request Mar 4, 2024
Copy link
Contributor

github-actions bot commented Mar 7, 2024

🎉 This PR is included in version 1.91.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link
Contributor

Because there has been no activity on this PR for 14 days since it was merged, it has been automatically locked. Please open a new issue if it requires a follow up.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants