JsonRpcErrorCode
Usage
import { JsonRpcError, JsonRpcErrorCode } from '@stacks/connect';
try {
const result = await request('stx_transferStx', {
recipient: 'SP2...address',
amount: 1000000n,
});
} catch (error) {
if (error instanceof JsonRpcError) {
switch (error.code) {
case JsonRpcErrorCode.UserRejection:
console.log('User rejected the request');
break;
case JsonRpcErrorCode.UserCanceled:
console.log('User canceled the request');
break;
case JsonRpcErrorCode.MethodNotFound:
console.log('Method not supported by wallet');
break;
default:
console.error('Unexpected error:', error.message);
}
}
}Definition
Standard JSON-RPC Errors
Code
Name
Description
Implementation-Defined Wallet Errors
Code
Name
Description
Custom Errors
Code
Name
Description
Last updated
Was this helpful?