CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-ledgerhq--errors

Comprehensive error handling system for Ledger hardware wallet applications and libraries

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

database-errors.mddocs/

Database Errors

Error classes for database operations and configuration issues in Ledger applications.

Types

interface DatabaseConfig {
  dbPath: string;
  password?: string;
  connectionTimeout?: number;
  maxRetries?: number;
}

Capabilities

Database Configuration Errors

Errors related to database path configuration and setup.

const NoDBPathGiven: CustomErrorFunc;

Usage Examples:

import { NoDBPathGiven } from "@ledgerhq/errors";

// Validate database path configuration
function initializeDatabase(config: DatabaseConfig) {
  if (!config.dbPath || config.dbPath.trim() === "") {
    throw new NoDBPathGiven("Database path must be specified in configuration");
  }
  
  return openDatabase(config.dbPath);
}

// Example database initialization
try {
  const db = initializeDatabase({ dbPath: process.env.DB_PATH });
} catch (error) {
  if (error instanceof NoDBPathGiven) {
    console.log("Please set DB_PATH environment variable");
  }
}

Database Authentication Errors

Errors related to database password validation and authentication.

const DBWrongPassword: CustomErrorFunc;

Usage Examples:

import { DBWrongPassword } from "@ledgerhq/errors";

// Handle database password validation
async function authenticateDatabase(password: string) {
  try {
    await verifyDatabasePassword(password);
  } catch (error) {
    throw new DBWrongPassword("Incorrect database password provided");
  }
}

// Example database access with password
try {
  await authenticateDatabase(userPassword);
  const db = await openSecureDatabase();
} catch (error) {
  if (error instanceof DBWrongPassword) {
    console.log("Invalid password - please try again");
    promptForPassword();
  }
}

Database State Errors

Errors related to database state management and reset operations.

const DBNotReset: CustomErrorFunc;

Usage Examples:

import { DBNotReset } from "@ledgerhq/errors";

// Handle database reset validation
async function initializeCleanDatabase() {
  const isReset = await checkDatabaseResetStatus();
  
  if (!isReset) {
    throw new DBNotReset("Database must be reset before initialization");
  }
  
  return createNewDatabase();
}

// Example database reset workflow
try {
  await resetDatabase();
  const db = await initializeCleanDatabase();
} catch (error) {
  if (error instanceof DBNotReset) {
    console.log("Database reset failed - please try manual reset");
  }
}

// Database migration with reset requirement
async function migrateDatabase(fromVersion: string, toVersion: string) {
  if (requiresReset(fromVersion, toVersion)) {
    try {
      await resetDatabase();
      await initializeCleanDatabase();
    } catch (error) {
      if (error instanceof DBNotReset) {
        throw new Error(`Migration from ${fromVersion} to ${toVersion} requires database reset`);
      }
    }
  }
}

docs

account-balance-errors.md

application-manager-errors.md

currency-transaction-errors.md

database-errors.md

device-management-errors.md

error-utilities.md

index.md

network-api-errors.md

transport-errors.md

user-interaction-errors.md

tile.json