Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Convert all errors in @solana/rpc-types to coded exceptions #2226

Conversation

steveluscher
Copy link
Contributor

@steveluscher steveluscher commented Mar 1, 2024

Addresses #2118.

@steveluscher
Copy link
Contributor Author

steveluscher commented Mar 1, 2024

@steveluscher steveluscher requested a review from buffalojoec March 1, 2024 00:59
@steveluscher steveluscher force-pushed the 02-29-Convert_errors_in_solana/signers_to_coded_exceptions branch from f0ad0e1 to 75de449 Compare March 1, 2024 01:05
@steveluscher steveluscher force-pushed the 03-01-Convert_all_errors_in_solana/rpc-types_to_coded_exceptions branch from fa52ec1 to 91d267b Compare March 1, 2024 01:05
Comment on lines -16 to -23
if (putativeLamports < 0) {
// TODO: Coded error.
throw new Error('Input for 64-bit unsigned integer cannot be negative');
}

if (putativeLamports > maxU64Value) {
// TODO: Coded error.
throw new Error('Input number is too large to be represented as a 64-bit unsigned integer');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sort of figured these both boiled down to ‘out of range.’

@steveluscher steveluscher force-pushed the 02-29-Convert_errors_in_solana/signers_to_coded_exceptions branch from 75de449 to e14a7ef Compare March 1, 2024 02:09
@steveluscher steveluscher force-pushed the 03-01-Convert_all_errors_in_solana/rpc-types_to_coded_exceptions branch from 91d267b to a583373 Compare March 1, 2024 02:09
Comment on lines 57 to 58
export const SOLANA_ERROR__BIGINT_STRING_MALFORMED = 51 as const;
export const SOLANA_ERROR__NUMBER_STRING_MALFORMED = 52 as const;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: We may want to stay consistent with other existing error names such as SOLANA_ERROR__MALFORMED_PROGRAM_DERIVED_ADDRESS and use MALFORMED as a prefixed instead of a suffix.

Unless we prefer the suffix version, in which case we should probably update the other ones.

Copy link
Contributor

Choose a reason for hiding this comment

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

I vote prefix!

@steveluscher steveluscher force-pushed the 02-29-Convert_errors_in_solana/signers_to_coded_exceptions branch from e14a7ef to 3b46917 Compare March 1, 2024 22:33
@steveluscher steveluscher force-pushed the 03-01-Convert_all_errors_in_solana/rpc-types_to_coded_exceptions branch from a583373 to 4ee6090 Compare March 1, 2024 22:33
@steveluscher
Copy link
Contributor Author

steveluscher commented Mar 1, 2024

Merge activity

  • Mar 1, 2:47 PM PST: @steveluscher started a stack merge that includes this pull request via Graphite.
  • Mar 1, 2:48 PM PST: Graphite couldn't merge this PR because it had conflicts with the trunk branch.
  • Mar 1, 2:51 PM PST: @steveluscher started a stack merge that includes this pull request via Graphite.
  • Mar 1, 2:57 PM PST: @steveluscher merged this pull request with Graphite.

Base automatically changed from 02-29-Convert_errors_in_solana/signers_to_coded_exceptions to master March 1, 2024 22:48
@steveluscher steveluscher force-pushed the 03-01-Convert_all_errors_in_solana/rpc-types_to_coded_exceptions branch from 4ee6090 to 696be96 Compare March 1, 2024 22:55
@steveluscher steveluscher merged commit 94fee67 into master Mar 1, 2024
4 of 6 checks passed
@steveluscher steveluscher deleted the 03-01-Convert_all_errors_in_solana/rpc-types_to_coded_exceptions branch March 1, 2024 22:57
Copy link
Contributor

github-actions bot commented Mar 2, 2024

🎉 This PR is included in version 1.90.1 🎉

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 19, 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.

3 participants