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

user-interaction-errors.mddocs/

0

# User Interaction Errors

1

2

Error classes for user interaction scenarios including user refusals, permission issues, and input validation failures.

3

4

## Capabilities

5

6

### User Refusal Errors

7

8

Errors for when users explicitly refuse or cancel operations on the device.

9

10

```typescript { .api }

11

const UserRefusedOnDevice: CustomErrorFunc;

12

const UserRefusedAddress: CustomErrorFunc;

13

const UserRefusedFirmwareUpdate: CustomErrorFunc;

14

const UserRefusedAllowManager: CustomErrorFunc;

15

const UserRefusedDeviceNameChange: CustomErrorFunc;

16

```

17

18

**Usage Examples:**

19

20

```typescript

21

import {

22

UserRefusedOnDevice,

23

UserRefusedAddress,

24

UserRefusedFirmwareUpdate,

25

UserRefusedAllowManager

26

} from "@ledgerhq/errors";

27

28

// Handle transaction refusal

29

try {

30

await signTransaction();

31

} catch (error) {

32

if (error instanceof UserRefusedOnDevice) {

33

console.log("User cancelled transaction on device");

34

showMessage("Transaction was cancelled by user");

35

}

36

}

37

38

// Handle address verification refusal

39

try {

40

await verifyAddress();

41

} catch (error) {

42

if (error instanceof UserRefusedAddress) {

43

console.log("User refused to verify address");

44

}

45

}

46

47

// Handle firmware update refusal

48

if (userResponse === "denied") {

49

throw new UserRefusedFirmwareUpdate("User declined firmware update");

50

}

51

52

// Handle manager access refusal

53

if (!allowManagerAccess) {

54

throw new UserRefusedAllowManager("User denied manager access permissions");

55

}

56

```

57

58

### Permission and Access Errors

59

60

Errors related to system permissions and hardware access.

61

62

```typescript { .api }

63

const NoAccessToCamera: CustomErrorFunc;

64

const CantScanQRCode: CustomErrorFunc;

65

const PairingFailed: CustomErrorFunc;

66

```

67

68

**Usage Examples:**

69

70

```typescript

71

import {

72

NoAccessToCamera,

73

CantScanQRCode,

74

PairingFailed

75

} from "@ledgerhq/errors";

76

77

// Handle camera permission

78

try {

79

await requestCameraAccess();

80

} catch (error) {

81

throw new NoAccessToCamera("Camera access required for QR code scanning");

82

}

83

84

// Handle QR code scanning issues

85

try {

86

const qrData = await scanQRCode();

87

} catch (error) {

88

if (error instanceof CantScanQRCode) {

89

console.log("Unable to scan QR code - check lighting and positioning");

90

}

91

}

92

93

// Handle device pairing failure

94

try {

95

await pairDevice();

96

} catch (error) {

97

if (error instanceof PairingFailed) {

98

console.log("Device pairing failed - please try again");

99

console.log("Ensure device is in pairing mode and nearby");

100

}

101

}

102

```

103

104

### Password and Authentication Errors

105

106

Errors related to password validation and authentication.

107

108

```typescript { .api }

109

const PasswordsDontMatchError: CustomErrorFunc;

110

const PasswordIncorrectError: CustomErrorFunc;

111

```

112

113

**Usage Examples:**

114

115

```typescript

116

import {

117

PasswordsDontMatchError,

118

PasswordIncorrectError

119

} from "@ledgerhq/errors";

120

121

// Handle password confirmation

122

function validatePasswordConfirmation(password: string, confirmPassword: string) {

123

if (password !== confirmPassword) {

124

throw new PasswordsDontMatchError("Password confirmation does not match");

125

}

126

}

127

128

// Handle incorrect password

129

try {

130

await authenticateUser(password);

131

} catch (error) {

132

if (error instanceof PasswordIncorrectError) {

133

console.log("Incorrect password entered");

134

attemptCount++;

135

if (attemptCount >= 3) {

136

lockAccount();

137

}

138

}

139

}

140

141

// Example usage in form validation

142

function handlePasswordForm(data: { password: string; confirmPassword: string }) {

143

try {

144

validatePasswordConfirmation(data.password, data.confirmPassword);

145

console.log("Password validation successful");

146

} catch (error) {

147

if (error instanceof PasswordsDontMatchError) {

148

showError("Passwords must match");

149

}

150

}

151

}

152

```