Skip to main content

Class: AuthenticationError

Defined in: src/types/errors.ts:263

Authentication error for failed authentication attempts.

Remarks

Thrown when:

  • Credentials are invalid
  • DID verification fails
  • Session token is missing or invalid
  • Multi-factor authentication fails

HTTP mapping: 401 Unauthorized

Example

if (!isValidDID(did)) {
throw new AuthenticationError('Invalid DID format');
}

Extends

Constructors

new AuthenticationError()

new AuthenticationError(message, cause?): AuthenticationError

Defined in: src/types/errors.ts:79

Creates a new ChiveError.

Parameters

message

string

Human-readable error message

cause?

Error

Original error (if chained)

Returns

AuthenticationError

Inherited from

ChiveError.constructor

Properties

cause?

readonly optional cause: Error

Defined in: src/types/errors.ts:71

Original error that caused this error (if any).

Remarks

Error chaining allows tracking the full error context through multiple layers of the application. Useful for debugging complex error scenarios.

Example

try {
await fetchData();
} catch (err) {
throw new ValidationError('Failed to validate data', 'field', 'required', err as Error);
}

Inherited from

ChiveError.cause


code

readonly code: "AUTHENTICATION_ERROR" = 'AUTHENTICATION_ERROR'

Defined in: src/types/errors.ts:264

Machine-readable error code.

Remarks

Error codes are unique identifiers for error types, enabling programmatic error handling (switch statements, error maps), error tracking in monitoring systems, and client-side error translation (i18n).

Overrides

ChiveError.code