Standardized auth error with categorization

Provides both machine-readable error types and human-readable messages. Each provider implements classifyErrorInternal() to map their specific errors to this standard format.

Example

const authError = this.authBase.classifyError(err);

// Log for debugging
console.error(`Auth error (${authError.type}):`, authError.message);

// Show to user
this.showErrorMessage(authError.userMessage || authError.message);

// Access original error for detailed debugging
if (environment.debug) {
console.error('Original error:', authError.originalError);
}
interface StandardAuthError {
    message: string;
    originalError?: unknown;
    type: AuthErrorType;
    userMessage?: string;
}

Properties

message: string

Technical error message

Suitable for logging and debugging. May contain technical details not appropriate for end users.

originalError?: unknown

Original error from the provider (for debugging)

Preserved for detailed error analysis and debugging. Can be any type (Error, object, string, etc.)

Semantic error type for programmatic handling

Use this in switch statements or if conditions to handle different error scenarios appropriately.

userMessage?: string

User-friendly error message

A message suitable for displaying to end users. Explains the error in plain language and may suggest next steps.

Example

"Your session has expired. Please log in again."