or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

configuration.mderrors.mdevents.mdindex.mdoidc-client.mdstorage.mduser-management.mduser-tokens.mdutilities.md

errors.mddocs/

0

# Error Handling

1

2

Comprehensive error types for authentication failures, timeouts, and protocol errors with detailed error information.

3

4

## Capabilities

5

6

### ErrorResponse

7

8

OAuth2/OIDC error responses from the authorization server.

9

10

```typescript { .api }

11

/**

12

* Error representing OAuth2/OIDC error responses

13

*/

14

class ErrorResponse extends Error {

15

constructor(args: {

16

error: string;

17

error_description?: string;

18

error_uri?: string;

19

state?: string;

20

session_state?: string;

21

});

22

23

/** OAuth2 error code */

24

readonly error: string;

25

/** Human-readable error description */

26

readonly error_description?: string;

27

/** URI with error information */

28

readonly error_uri?: string;

29

/** State parameter from request */

30

readonly state?: string;

31

/** Session state */

32

readonly session_state?: string;

33

}

34

```

35

36

### ErrorTimeout

37

38

Request timeout errors.

39

40

```typescript { .api }

41

/**

42

* Error for request timeout scenarios

43

*/

44

class ErrorTimeout extends Error {

45

constructor(message?: string);

46

}

47

```

48

49

### DPoP Errors

50

51

DPoP-specific error handling. Note: These errors may be thrown internally but are not exported classes.

52

53

```typescript { .api }

54

/**

55

* Error for DPoP nonce validation failures (internal error type)

56

*/

57

class ErrorDPoPNonce extends Error {

58

constructor(nonce: string, message?: string);

59

60

/** The nonce value that caused the error */

61

readonly nonce: string;

62

/** Error type marker */

63

readonly name: "ErrorDPoPNonce";

64

}

65

```

66

67

## Usage Examples

68

69

```typescript

70

import { UserManager, ErrorResponse, ErrorTimeout } from "oidc-client-ts";

71

72

const userManager = new UserManager({

73

// ... configuration

74

});

75

76

try {

77

const user = await userManager.signinRedirect();

78

} catch (error) {

79

if (error instanceof ErrorResponse) {

80

console.error("OAuth2 Error:", {

81

code: error.error,

82

description: error.error_description,

83

uri: error.error_uri,

84

});

85

86

// Handle specific error codes

87

switch (error.error) {

88

case "access_denied":

89

showMessage("Access was denied by the user");

90

break;

91

case "invalid_request":

92

showMessage("Invalid authentication request");

93

break;

94

case "server_error":

95

showMessage("Authentication server error");

96

break;

97

default:

98

showMessage(`Authentication failed: ${error.error_description}`);

99

}

100

} else if (error instanceof ErrorTimeout) {

101

console.error("Request timeout:", error.message);

102

showMessage("Authentication request timed out");

103

} else {

104

console.error("Unknown error:", error);

105

showMessage("An unexpected error occurred");

106

}

107

}

108

```