Comprehensive error handling library for the Ledger ecosystem with unified error classes, serialization, and hardware wallet status codes
Error classes specific to Ledger hardware device operations, authentication, device state management, and firmware-related issues.
Error classes for device communication and connection issues.
const CantOpenDevice: CustomErrorFunc;
const DisconnectedDevice: CustomErrorFunc;
const DisconnectedDeviceDuringOperation: CustomErrorFunc;
const DeviceSocketFail: CustomErrorFunc;
const DeviceSocketNoBulkStatus: CustomErrorFunc;Usage Examples:
import {
CantOpenDevice,
DisconnectedDevice,
DisconnectedDeviceDuringOperation,
DeviceSocketFail
} from "@ledgerhq/errors";
// Device cannot be opened
throw new CantOpenDevice("Unable to establish connection to Ledger device");
// Device disconnected unexpectedly
throw new DisconnectedDevice("Ledger device was disconnected");
// Device disconnected during operation
throw new DisconnectedDeviceDuringOperation("Device disconnected while signing transaction");
// Socket communication failure
throw new DeviceSocketFail("Failed to establish socket connection with device");Error classes for device authenticity verification and security validation.
const DeviceNotGenuineError: CustomErrorFunc;
const DeviceGenuineSocketEarlyClose: CustomErrorFunc;
const MCUNotGenuineToDashboard: CustomErrorFunc;
const GenuineCheckFailed: CustomErrorFunc;Usage Examples:
import {
DeviceNotGenuineError,
DeviceGenuineSocketEarlyClose,
GenuineCheckFailed
} from "@ledgerhq/errors";
// Device authenticity verification failed
throw new DeviceNotGenuineError("Device failed genuine check - may not be authentic Ledger device");
// Genuine check socket closed prematurely
throw new DeviceGenuineSocketEarlyClose("Genuine check connection closed unexpectedly");
// General genuine check failure
throw new GenuineCheckFailed("Unable to verify device authenticity");Error classes for device state management and expected states.
const DeviceOnDashboardExpected: CustomErrorFunc;
const DeviceOnDashboardUnexpected: CustomErrorFunc;
const DeviceInOSUExpected: CustomErrorFunc;
const DeviceShouldStayInApp: CustomErrorFunc;
const DeviceHalted: CustomErrorFunc;
const UnexpectedBootloader: CustomErrorFunc;Usage Examples:
import {
DeviceOnDashboardExpected,
DeviceOnDashboardUnexpected,
DeviceInOSUExpected,
DeviceShouldStayInApp,
DeviceHalted
} from "@ledgerhq/errors";
// Device should be on dashboard
throw new DeviceOnDashboardExpected("Please navigate to the dashboard on your Ledger device");
// Device should not be on dashboard
throw new DeviceOnDashboardUnexpected("Please open the appropriate app on your Ledger device");
// Device should be in OSU mode for firmware update
throw new DeviceInOSUExpected("Device must be in OSU (OS Update) mode for this operation");
// Device should remain in current app
throw new DeviceShouldStayInApp("Please remain in the current app on your device");
// Device is in halted state
throw new DeviceHalted("Device is halted - please restart your Ledger device");Error classes for device naming and configuration issues.
const DeviceNameInvalid: CustomErrorFunc;
const UserRefusedDeviceNameChange: CustomErrorFunc;
const BluetoothRequired: CustomErrorFunc;Usage Examples:
import {
DeviceNameInvalid,
UserRefusedDeviceNameChange,
BluetoothRequired
} from "@ledgerhq/errors";
// Invalid device name format
throw new DeviceNameInvalid("Device name contains invalid characters");
// User declined device name change
throw new UserRefusedDeviceNameChange("User refused to change device name");
// Bluetooth required for operation
throw new BluetoothRequired("Bluetooth must be enabled for this operation");Error classes for firmware validation, updates, and MCU (Microcontroller Unit) operations.
const FirmwareNotRecognized: CustomErrorFunc;
const FirmwareOrAppUpdateRequired: CustomErrorFunc;
const LatestMCUInstalledError: CustomErrorFunc;
const UnknownMCU: CustomErrorFunc;
const HardResetFail: CustomErrorFunc;Usage Examples:
import {
FirmwareNotRecognized,
FirmwareOrAppUpdateRequired,
LatestMCUInstalledError,
UnknownMCU,
HardResetFail
} from "@ledgerhq/errors";
// Firmware version not recognized
throw new FirmwareNotRecognized("Device firmware version is not recognized");
// Update required
throw new FirmwareOrAppUpdateRequired("Please update your device firmware or app");
// Latest MCU already installed
throw new LatestMCUInstalledError("Latest MCU version is already installed");
// Unknown MCU type
throw new UnknownMCU("MCU type is not recognized");
// Hard reset operation failed
throw new HardResetFail("Failed to perform hard reset on device");Error classes for firmware updates and software installation processes.
const UpdateFetchFileFail: CustomErrorFunc;
const UpdateIncorrectHash: CustomErrorFunc;
const UpdateIncorrectSig: CustomErrorFunc;
const UpdateYourApp: CustomErrorFunc;Usage Examples:
import {
UpdateFetchFileFail,
UpdateIncorrectHash,
UpdateIncorrectSig,
UpdateYourApp
} from "@ledgerhq/errors";
// Failed to download update file
throw new UpdateFetchFileFail("Could not download firmware update file");
// Update file hash verification failed
throw new UpdateIncorrectHash("Update file hash does not match expected value");
// Update file signature verification failed
throw new UpdateIncorrectSig("Update file signature verification failed");
// App update required
throw new UpdateYourApp("Please update the app on your device");Error classes for device app verification and compatibility checks.
const DeviceAppVerifyNotSupported: CustomErrorFunc;
const BtcUnmatchedApp: CustomErrorFunc;
const WrongAppForCurrency: CustomErrorFunc;
const EthAppPleaseEnableContractData: CustomErrorFunc;Usage Examples:
import {
DeviceAppVerifyNotSupported,
BtcUnmatchedApp,
WrongAppForCurrency,
EthAppPleaseEnableContractData
} from "@ledgerhq/errors";
// App verification not supported on this device
throw new DeviceAppVerifyNotSupported("App verification is not supported on this device firmware");
// Bitcoin app mismatch
throw new BtcUnmatchedApp("Bitcoin app version does not match requirements");
// Wrong app for cryptocurrency
throw new WrongAppForCurrency("Please open the correct app for this cryptocurrency", {
expectedApp: "Ethereum",
currentApp: "Bitcoin"
});
// Ethereum app requires contract data to be enabled
throw new EthAppPleaseEnableContractData("Please enable contract data in the Ethereum app settings");type CustomErrorFunc = (
message?: string,
fields?: { [key: string]: any }
) => void;tessl i tessl/npm-ledgerhq--errors@5.50.0