Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@wallet-standard/errors
Advanced tools
This package brings together every error message across all Wallet Standard JavaScript modules.
@wallet-standard/errors
This package brings together every error message across all Wallet Standard JavaScript modules.
When your bundler sets the environment variable NODE_ENV
to development
, 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
NODE_ENV
set toproduction
when you go to production.
When your bundler sets the environment variable NODE_ENV
to anything other than development
, 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
:
npx @wallet-standard/errors decode -- 123
src/codes.ts
.WalletStandardErrorCode
union in src/codes.ts
.src/context.ts
.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`'
).@wallet-standard/errors
.@wallet-standard/errors
in the package from which the error is thrown.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.
When you catch a WalletStandardError
and assert its error code using isWalletStandardError()
, TypeScript will refine the error's context to the type associated with that error code. You can use that context to render useful error messages, or to make context-aware decisions that help your application to recover from the error.
import { WALLET_STANDARD_ERROR__ACCOUNT__FEATURE_NOT_SUPPORTED, isWalletStandardError } from '@wallet-standard/errors';
function MyComponent(props) {
return (
<ErrorBoundary FallbackComponent={ErrorComponent}>
<SignMessageForm account={props.account} />
</ErrorBoundary>
);
}
function ErrorComponent({ error }) {
if (
isWalletStandardError(error, WALLET_STANDARD_ERROR__ACCOUNT__FEATURE_NOT_SUPPORTED) &&
error.context.featureName === 'solana:signMessage'
) {
return (
<span>
The account <AccountLink account={error.account} /> does not support signing messages. Please choose
another account.
</span>
);
} else if (error && typeof error === 'object' && 'message' in error) {
return <span>{String(error.message)}</span>;
} else {
return <span>Something went wrong</span>;
}
}
FAQs
This package brings together every error message across all Wallet Standard JavaScript modules.
We found that @wallet-standard/errors demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.