DecaneDocs
ReferenceError handling
Reference

Error handling

All hooks return error: DecaneError | null. Branch on error.code instead of parsing error strings.

tsx
import { DecaneError, DecaneErrorCode } from "decane-connect-kit";

if (error) {
  switch (error.code) {
    case DecaneErrorCode.USER_REJECTED:
      break;
    case DecaneErrorCode.NO_ACTIVE_SESSION:
      break;
    default:
      console.error(error.message);
  }
}

Error codes

CodeValueWhen thrown
USER_REJECTED4001User dismissed the wallet prompt
UNAUTHORIZED4100Wallet refused the request
NO_ACTIVE_SESSION5001Signing called before connecting
SCOPE_MISMATCH5002Account not in session scope
SESSION_EXPIRED5003Session is no longer valid
UNSUPPORTED_CHAIN5010Chain ID not in registry
CHAIN_NOT_IN_SCOPE5011Chain not granted in session
INVALID_CHAIN_CONFIG5012Custom chain descriptor is malformed
NO_WALLET_CONNECTED5020Action requires a connected wallet
WALLET_DISCONNECTED5021Wallet disconnected mid-session
PROVIDER_ERROR5022Underlying wallet threw an error
METHOD_NOT_SUPPORTED5030Method not recognised
EVM_ONLY_METHOD5031wallet_signTypedData on a non-EVM chain