If a Snap throws a SnapError (standardised error class), the Snap should not crash. This is useful in non-JSON-RPC contexts, such as onTransaction, onCronjob. The SnapError should be serialisable to JSON internally:
throw new SnapError(error);
// { code: -32000; message: error.message; data: { stack: error.stack }}
throw new SnapError('message'); -->
// { code: -32000; message: 'message'; }
throw new SnapError({ code: ...; message: ...; });
// { code: ...; message: ...; }
Related to #1779.
If a Snap throws a
SnapError(standardised error class), the Snap should not crash. This is useful in non-JSON-RPC contexts, such asonTransaction,onCronjob. TheSnapErrorshould be serialisable to JSON internally:Related to #1779.