or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

account-balance-errors.mdapplication-manager-errors.mdcurrency-transaction-errors.mddatabase-errors.mddevice-management-errors.mderror-utilities.mdindex.mdnetwork-api-errors.mdtransport-errors.mduser-interaction-errors.md
tile.json

database-errors.mddocs/

0

# Database Errors

1

2

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

3

4

## Types

5

6

```typescript { .api }

7

interface DatabaseConfig {

8

dbPath: string;

9

password?: string;

10

connectionTimeout?: number;

11

maxRetries?: number;

12

}

13

```

14

15

## Capabilities

16

17

### Database Configuration Errors

18

19

Errors related to database path configuration and setup.

20

21

```typescript { .api }

22

const NoDBPathGiven: CustomErrorFunc;

23

```

24

25

**Usage Examples:**

26

27

```typescript

28

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

29

30

// Validate database path configuration

31

function initializeDatabase(config: DatabaseConfig) {

32

if (!config.dbPath || config.dbPath.trim() === "") {

33

throw new NoDBPathGiven("Database path must be specified in configuration");

34

}

35

36

return openDatabase(config.dbPath);

37

}

38

39

// Example database initialization

40

try {

41

const db = initializeDatabase({ dbPath: process.env.DB_PATH });

42

} catch (error) {

43

if (error instanceof NoDBPathGiven) {

44

console.log("Please set DB_PATH environment variable");

45

}

46

}

47

```

48

49

### Database Authentication Errors

50

51

Errors related to database password validation and authentication.

52

53

```typescript { .api }

54

const DBWrongPassword: CustomErrorFunc;

55

```

56

57

**Usage Examples:**

58

59

```typescript

60

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

61

62

// Handle database password validation

63

async function authenticateDatabase(password: string) {

64

try {

65

await verifyDatabasePassword(password);

66

} catch (error) {

67

throw new DBWrongPassword("Incorrect database password provided");

68

}

69

}

70

71

// Example database access with password

72

try {

73

await authenticateDatabase(userPassword);

74

const db = await openSecureDatabase();

75

} catch (error) {

76

if (error instanceof DBWrongPassword) {

77

console.log("Invalid password - please try again");

78

promptForPassword();

79

}

80

}

81

```

82

83

### Database State Errors

84

85

Errors related to database state management and reset operations.

86

87

```typescript { .api }

88

const DBNotReset: CustomErrorFunc;

89

```

90

91

**Usage Examples:**

92

93

```typescript

94

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

95

96

// Handle database reset validation

97

async function initializeCleanDatabase() {

98

const isReset = await checkDatabaseResetStatus();

99

100

if (!isReset) {

101

throw new DBNotReset("Database must be reset before initialization");

102

}

103

104

return createNewDatabase();

105

}

106

107

// Example database reset workflow

108

try {

109

await resetDatabase();

110

const db = await initializeCleanDatabase();

111

} catch (error) {

112

if (error instanceof DBNotReset) {

113

console.log("Database reset failed - please try manual reset");

114

}

115

}

116

117

// Database migration with reset requirement

118

async function migrateDatabase(fromVersion: string, toVersion: string) {

119

if (requiresReset(fromVersion, toVersion)) {

120

try {

121

await resetDatabase();

122

await initializeCleanDatabase();

123

} catch (error) {

124

if (error instanceof DBNotReset) {

125

throw new Error(`Migration from ${fromVersion} to ${toVersion} requires database reset`);

126

}

127

}

128

}

129

}

130

```