Comprehensive error handling library for the Ledger ecosystem with unified error classes, serialization, and hardware wallet status codes
Error classes for input validation, address verification, transaction parameter validation, and required field checking.
Error classes for missing required parameters in transactions and operations.
const AmountRequired: CustomErrorFunc;
const RecipientRequired: CustomErrorFunc;
const FeeRequired: CustomErrorFunc;Usage Examples:
import {
AmountRequired,
RecipientRequired,
FeeRequired
} from "@ledgerhq/errors";
// Transaction amount is required
throw new AmountRequired("Transaction amount must be specified");
// Recipient address is required
throw new RecipientRequired("Recipient address is required for transaction");
// Transaction fee is required
throw new FeeRequired("Transaction fee must be specified", {
suggestedFeeRange: "0.0001 - 0.001 BTC"
});Error classes for address format validation and address-related checks.
const InvalidAddress: CustomErrorFunc;
const InvalidAddressBecauseDestinationIsAlsoSource: CustomErrorFunc;
const InvalidXRPTag: CustomErrorFunc;
const ETHAddressNonEIP: CustomErrorFunc;Usage Examples:
import {
InvalidAddress,
InvalidAddressBecauseDestinationIsAlsoSource,
InvalidXRPTag,
ETHAddressNonEIP
} from "@ledgerhq/errors";
// Invalid address format
throw new InvalidAddress("Invalid address format", {
providedAddress: "invalid_address_123",
expectedFormat: "Bitcoin address (P2PKH, P2SH, or Bech32)"
});
// Destination same as source address
throw new InvalidAddressBecauseDestinationIsAlsoSource(
"Destination address cannot be the same as source address"
);
// Invalid XRP destination tag
throw new InvalidXRPTag("Invalid XRP destination tag", {
providedTag: "abc123",
expectedFormat: "Numeric value between 0 and 4294967295"
});
// Ethereum address not EIP compliant
throw new ETHAddressNonEIP("Ethereum address is not EIP-55 compliant", {
providedAddress: "0xabcdef1234567890abcdef1234567890abcdef12",
correctChecksum: "0xAbCdEf1234567890aBcDeF1234567890AbCdEf12"
});Error classes for transaction fee validation and fee-related issues.
const FeeNotLoaded: CustomErrorFunc;
const FeeTooHigh: CustomErrorFunc;
const FeeEstimationFailed: CustomErrorFunc;Usage Examples:
import {
FeeNotLoaded,
FeeTooHigh,
FeeEstimationFailed
} from "@ledgerhq/errors";
// Fee information not loaded
throw new FeeNotLoaded("Transaction fee information has not been loaded", {
action: "Please wait for fee estimation to complete"
});
// Fee amount is too high
throw new FeeTooHigh("Transaction fee is unusually high", {
proposedFee: "0.01 BTC",
suggestedMaxFee: "0.001 BTC",
warningThreshold: "5% of transaction amount"
});
// Fee estimation failed
throw new FeeEstimationFailed("Unable to estimate transaction fee", {
reason: "Network congestion",
suggestedAction: "Try again later or set fee manually"
});Error classes for camera access, permissions, and security-related validation.
const NoAccessToCamera: CustomErrorFunc;
const CantScanQRCode: CustomErrorFunc;Usage Examples:
import {
NoAccessToCamera,
CantScanQRCode
} from "@ledgerhq/errors";
// Camera access denied
throw new NoAccessToCamera("Camera access is required to scan QR codes", {
action: "Please grant camera permission in browser settings"
});
// QR code scanning failed
throw new CantScanQRCode("Unable to scan QR code", {
possibleReasons: [
"QR code is damaged or unclear",
"Insufficient lighting",
"Camera focus issues"
]
});Error classes for password validation and authentication failures.
const PasswordsDontMatchError: CustomErrorFunc;
const PasswordIncorrectError: CustomErrorFunc;Usage Examples:
import {
PasswordsDontMatchError,
PasswordIncorrectError
} from "@ledgerhq/errors";
// Password confirmation doesn't match
throw new PasswordsDontMatchError("Password and confirmation password do not match");
// Incorrect password provided
throw new PasswordIncorrectError("Incorrect password provided", {
attemptsRemaining: 2,
maxAttempts: 3
});Error classes for device pairing and connection validation.
const PairingFailed: CustomErrorFunc;Usage Examples:
import { PairingFailed } from "@ledgerhq/errors";
// Device pairing failed
throw new PairingFailed("Failed to pair with Ledger device", {
connectionType: "Bluetooth",
troubleshooting: [
"Ensure device is in pairing mode",
"Check Bluetooth is enabled",
"Try restarting both devices"
]
});Error classes for data synchronization and sync-related issues.
const SyncError: CustomErrorFunc;
const TimeoutTagged: CustomErrorFunc;Usage Examples:
import {
SyncError,
TimeoutTagged
} from "@ledgerhq/errors";
// General synchronization error
throw new SyncError("Failed to synchronize account data", {
accountId: "btc_account_1",
lastSyncTime: "2023-01-01T12:00:00Z",
retryIn: "30 seconds"
});
// Operation timed out
throw new TimeoutTagged("Operation timed out", {
operation: "transaction_broadcast",
timeoutDuration: "30 seconds",
suggestedAction: "Retry with longer timeout"
});Error classes for endpoint and configuration validation.
const EnpointConfigError: CustomErrorFunc;Usage Examples:
import { EnpointConfigError } from "@ledgerhq/errors";
// Endpoint configuration error
throw new EnpointConfigError("Invalid endpoint configuration", {
endpoint: "https://api.example.com/invalid",
expectedFormat: "https://api.ledger.com/v1/",
configFile: "config.json"
});type CustomErrorFunc = (
message?: string,
fields?: { [key: string]: any }
) => void;tessl i tessl/npm-ledgerhq--errors@5.50.0