-
Notifications
You must be signed in to change notification settings - Fork 9
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
Document @solana/errors
with TypeDoc
#66
Merged
+156
−13
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,68 @@ | ||
/** | ||
* This package brings together every error message across all Solana JavaScript modules. | ||
* | ||
* # Reading error messages | ||
* | ||
* ## In development mode | ||
* | ||
* When your bundler sets the constant `__DEV__` to `true`, every error message will be included in | ||
* the bundle. As such, you will be able to read them in plain language wherever they appear. | ||
* | ||
* > [!WARNING] | ||
* > The size of your JavaScript bundle will increase significantly with the inclusion of every | ||
* > error message in development mode. Be sure to build your bundle with `__DEV__` set to `false` | ||
* > when you go to production. | ||
* | ||
* ## In production mode | ||
* | ||
* When your bundler sets the constant `__DEV__` to `false`, error messages will be stripped from | ||
* the bundle to save space. Only the error code will appear when an error is encountered. Follow | ||
* the instructions in the error message to convert the error code back to the human-readable error | ||
* message. | ||
* | ||
* For instance, to recover the error text for the error with code `123`: | ||
* | ||
* ```package-install | ||
* npx @solana/errors decode -- 123 | ||
* ``` | ||
* | ||
* > [!IMPORTANT] | ||
* > The string representation of a {@link SolanaError} should not be shown to users. Developers | ||
* > should use {@link isSolanaError} to distinguish the type of a thrown error, then show a custom, | ||
* > localized error message appropriate for their application's audience. Custom error messages | ||
* > should use the error's {@link SolanaError#context | `context`} if it would help the reader | ||
* > understand what happened and/or what to do next. | ||
Comment on lines
+29
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added this. |
||
* | ||
* # Adding a new error | ||
* | ||
* 1. Add a new exported error code constant to `src/codes.ts`. | ||
* 2. Add that new constant to the {@link SolanaErrorCode} union in `src/codes.ts`. | ||
* 3. If you would like the new error to encapsulate context about the error itself (eg. the public | ||
* keys for which a transaction is missing signatures) define the shape of that context in | ||
* `src/context.ts`. | ||
* 4. Add the error's message to `src/messages.ts`. Any context values that you defined above will | ||
* be interpolated into the message wherever you write `$key`, where `key` is the index of a | ||
* value in the context (eg. ``'Missing a signature for account `$address`'``). | ||
* 5. Publish a new version of `@solana/errors`. | ||
* 6. Bump the version of `@solana/errors` in the package from which the error is thrown. | ||
* | ||
* # Removing an error message | ||
* | ||
* - Don't remove errors. | ||
* - Don't change the meaning of an error message. | ||
* - Don't change or reorder error codes. | ||
* - Don't change or remove members of an error's context. | ||
* | ||
* When an older client throws an error, we want to make sure that they can always decode the error. | ||
* If you make any of the changes above, old clients will, by definition, not have received your | ||
* changes. This could make the errors that they throw impossible to decode going forward. | ||
* | ||
* # Catching errors | ||
* | ||
* See {@link isSolanaError} for an example of how to handle a caught {@link SolanaError}. | ||
* | ||
* @packageDocumentation | ||
*/ | ||
export * from './codes'; | ||
export * from './error'; | ||
export * from './json-rpc-error'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"$schema": "https://typedoc.org/schema.json", | ||
"extends": ["../typedoc.base.json"], | ||
"entryPoints": ["src/index.ts"] | ||
"entryPoints": ["src/index.ts"], | ||
"readme": "none" | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully documenting this here will make it show in in people's autocomplete, then they'll see the example, and better understand how to take advantage of the full power of this assertion.