UNPKG

@thalorlabs/errors

Version:

Enhanced exception handling system for TypeScript applications with comprehensive error classes and debugging capabilities

26 lines (25 loc) 1.06 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.AuthenticationError = void 0; const types_1 = require("@thalorlabs/types"); const CustomError_1 = __importDefault(require("./CustomError")); /** * Error for authentication failures. * * Used when authentication credentials are invalid or missing. * Provides clear 401 error responses with optional authentication context. * * @example * throw new AuthenticationError('Invalid token', 'token-expired', 'req-123'); * * throw new AuthenticationError('Authentication failed', null, 'req-456', { provider: 'oauth' }); */ class AuthenticationError extends CustomError_1.default { constructor(message = 'Unauthorized', error, requestId, context) { super(types_1.EHttpClientErrorResponse.UNAUTHORIZED, `${message}${error ? `: ${error}` : ''}`, requestId, context); } } exports.AuthenticationError = AuthenticationError;