trustwallet / wizard-sdk

Wizard-SDK, a TypeScript software development kit, is designed to visualize diverse protocol EIP-712 messages and simulate transactions that users sign daily in the web3.0 environment.
Apache License 2.0
26 stars 7 forks source link

feat: add custom errors #22

Closed a6-dou closed 1 year ago

a6-dou commented 1 year ago

added WizardError instance to define custom errors

the custom error can be identified in a catch block by checking the error name:

error.name === "WizardError"

This will allow more flexible error handling by application, The custom error WizardError is meant for soft errors, for example unsupported chain, unexpected protocol strategy change..etc

The normal Error is meant for internal errors (assert statements)

For more details see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors