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
└── SigningErrorError 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
| Code | Class | Description |
|---|---|---|
NOT_AUTHENTICATED | AuthError | No active session; user must log in |
SESSION_EXPIRED | AuthError | Session token has expired |
TOKEN_EXPIRED | AuthError | Access token expired; SDK auto-refreshes |
INVALID_PROVIDER | AuthError | Unknown OAuth provider specified |
Wallet Errors
| Code | Class | Description |
|---|---|---|
RECOVERY_REQUIRED | WalletError | Local key share missing; run recovery flow |
WALLET_NOT_FOUND | WalletError | No wallet generated yet |
Protocol Errors
| Code | Class | Description |
|---|---|---|
DKG_FAILED | ProtocolError | Distributed Key Generation failed |
DKLS_KEYGEN_FAILED | ProtocolError | Error during DKLS key generation |
SIGNING_SESSION_CONFLICT | ProtocolError | Another signing session is active |
SIGNING_FAILED | ProtocolError | Signing protocol error |
INVALID_SHARE | ProtocolError | Peer share verification failure |
Network Errors
| Code | Class | Description |
|---|---|---|
NETWORK_ERROR | NetworkError | Backend unreachable |
TIMEOUT | NetworkError | Request timed out |
ClientKeyManager Errors
| Code | Method | Condition |
|---|---|---|
USER_NOT_INITIALIZED | Storage write methods | currentUserId is null |
NO_KEY_SHARE | rotateKeyShare, exportBackup | No key share exists for current user |
PARTY_ID_MISMATCH | rotateKeyShare | Incoming party ID differs from existing share |
INVALID_BACKUP | importBackup | backup.type is not "nero-mpc-backup" |
UNSUPPORTED_VERSION | importBackup | backup.version is not 1 |
INVALID_PUBLIC_KEY | deriveEOAAddress | Public key hex length not 128 or 130 characters |
EIP-1193 Provider Errors
Standard provider errors following the EIP-1193 specification:
| Code | Name | Description |
|---|---|---|
| 4001 | USER_REJECTED | User rejected the request |
| 4100 | UNAUTHORIZED | Provider lacks authorization |
| 4200 | UNSUPPORTED_METHOD | RPC method not implemented |
| 4900 | DISCONNECTED | Provider disconnected from chain |
| 4902 | CHAIN_NOT_ADDED | Requested 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
| Code | Recommended Recovery |
|---|---|
NOT_AUTHENTICATED | Call login() or redirect to login page |
SESSION_EXPIRED | Re-authenticate the user |
TOKEN_EXPIRED | SDK auto-refreshes; retry the operation |
RECOVERY_REQUIRED | Run the recovery flow with user's backup password |
WALLET_NOT_FOUND | Call generateWallet() |
DKG_FAILED | Retry generateWallet() |
DKLS_KEYGEN_FAILED | Retry key generation |
SIGNING_SESSION_CONFLICT | Wait and retry the signing operation |
SIGNING_FAILED | Retry the signing operation |
INVALID_SHARE | Re-run key generation |
NETWORK_ERROR | Check connectivity and retry with backoff |
TIMEOUT | Retry with backoff |
React Hook Error Handling
All React hooks follow a consistent four-step error propagation pattern:
- Caught within the hook's
useCallback - Normalized to standard Error object
- Stored in the hook's
errorstate for UI rendering - Re-thrown to allow component-level handling
Operations always reset error to null at start and reset loading flags in finally blocks.