NERO
API Reference

Errors

Complete error class hierarchy, error codes, and handling patterns

Error Reference

The SDK uses a unified SDKError class hierarchy for domain-specific failures with typed error codes across all operations.

SDKError Class Hierarchy

SDKError (base)
├── AuthError
├── WalletError
├── ProtocolError
├── NetworkError
└── SigningError

Error Classes

SDKError (Base)

The root error class for all SDK-specific failures. All subclasses inherit code and optional details.

class SDKError extends Error {
  code: SDKErrorCode;
  details?: Record<string, unknown>;
}

AuthError

Thrown for authentication and session-related failures.

class AuthError extends SDKError {
  code: string;
  details?: Record<string, unknown>;
}

WalletError

Thrown for wallet generation and signing failures.

class WalletError extends SDKError {
  code: string;
  details?: Record<string, unknown>;
}

ProtocolError

Thrown for MPC protocol round failures. Includes an optional round field indicating which protocol round encountered the error.

class ProtocolError extends SDKError {
  code: string;
  round?: number;
  details?: Record<string, unknown>;
}

NetworkError

Thrown for HTTP and WebSocket communication failures. Includes an optional statusCode for HTTP error responses.

class NetworkError extends SDKError {
  code: string;
  statusCode?: number;
  details?: Record<string, unknown>;
}

SigningError

Thrown for failures during the MPC signing process.

class SigningError extends SDKError {
  code: string;
  details?: Record<string, unknown>;
}

Error Codes

Authentication Errors

CodeClassDescription
NOT_AUTHENTICATEDAuthErrorNo active session; user must log in
SESSION_EXPIREDAuthErrorSession token has expired
TOKEN_EXPIREDAuthErrorAccess token expired; SDK auto-refreshes
INVALID_PROVIDERAuthErrorUnknown OAuth provider specified

Wallet Errors

CodeClassDescription
RECOVERY_REQUIREDWalletErrorLocal key share missing; run recovery flow
WALLET_NOT_FOUNDWalletErrorNo wallet generated yet

Protocol Errors

CodeClassDescription
DKG_FAILEDProtocolErrorDistributed Key Generation failed
DKLS_KEYGEN_FAILEDProtocolErrorError during DKLS key generation
SIGNING_SESSION_CONFLICTProtocolErrorAnother signing session is active
SIGNING_FAILEDProtocolErrorSigning protocol error
INVALID_SHAREProtocolErrorPeer share verification failure

Network Errors

CodeClassDescription
NETWORK_ERRORNetworkErrorBackend unreachable
TIMEOUTNetworkErrorRequest timed out

ClientKeyManager Errors

CodeMethodCondition
USER_NOT_INITIALIZEDStorage write methodscurrentUserId is null
NO_KEY_SHARErotateKeyShare, exportBackupNo key share exists for current user
PARTY_ID_MISMATCHrotateKeyShareIncoming party ID differs from existing share
INVALID_BACKUPimportBackupbackup.type is not "nero-mpc-backup"
UNSUPPORTED_VERSIONimportBackupbackup.version is not 1
INVALID_PUBLIC_KEYderiveEOAAddressPublic key hex length not 128 or 130 characters

EIP-1193 Provider Errors

Standard provider errors following the EIP-1193 specification:

CodeNameDescription
4001USER_REJECTEDUser rejected the request
4100UNAUTHORIZEDProvider lacks authorization
4200UNSUPPORTED_METHODRPC method not implemented
4900DISCONNECTEDProvider disconnected from chain
4902CHAIN_NOT_ADDEDRequested chain not added to SDK

Error Handling Patterns

Basic Pattern

try {
  await sdk.signMessage("test");
} catch (error) {
  if (error.code === "NOT_AUTHENTICATED") {
    // Redirect to login
  } else if (error.code === "RECOVERY_REQUIRED") {
    // Initiate recovery flow
  } else if (error.code === "SIGNING_SESSION_CONFLICT") {
    // Wait for current session to complete, then retry
  } else if (error.code === "NETWORK_ERROR") {
    // Check connectivity and retry
  }
}

Recovery Strategies by Error Code

CodeRecommended Recovery
NOT_AUTHENTICATEDCall login() or redirect to login page
SESSION_EXPIREDRe-authenticate the user
TOKEN_EXPIREDSDK auto-refreshes; retry the operation
RECOVERY_REQUIREDRun the recovery flow with user's backup password
WALLET_NOT_FOUNDCall generateWallet()
DKG_FAILEDRetry generateWallet()
DKLS_KEYGEN_FAILEDRetry key generation
SIGNING_SESSION_CONFLICTWait and retry the signing operation
SIGNING_FAILEDRetry the signing operation
INVALID_SHARERe-run key generation
NETWORK_ERRORCheck connectivity and retry with backoff
TIMEOUTRetry with backoff

React Hook Error Handling

All React hooks follow a consistent four-step error propagation pattern:

  1. Caught within the hook's useCallback
  2. Normalized to standard Error object
  3. Stored in the hook's error state for UI rendering
  4. Re-thrown to allow component-level handling

Operations always reset error to null at start and reset loading flags in finally blocks.

On this page