/** * Custom Error Classes for ABAC Engine * * Provides a hierarchical error system with proper context and categorization * for different types of failures in the ABAC engine. */ /** * Base error class for all ABAC-related errors */ export declare class ABACError extends Error { readonly code: string; readonly context: Record | undefined; readonly timestamp: Date; constructor(message: string, code: string, context?: Record); /** * Returns a formatted error message with context */ toJSON(): Record; } /** * Thrown when policy or request validation fails */ export declare class ValidationError extends ABACError { readonly validationErrors: Array<{ field: string; message: string; }>; constructor(message: string, validationErrors: Array<{ field: string; message: string; }>, context?: Record); static fromValidationResult(policyId: string, errors: Array<{ path: string; message: string; }>): ValidationError; } /** * Thrown when configuration or initialization fails */ export declare class ConfigurationError extends ABACError { constructor(message: string, context?: Record); static missingConfiguration(field: string): ConfigurationError; static invalidConfiguration(field: string, reason: string): ConfigurationError; } /** * Thrown when policy evaluation fails */ export declare class EvaluationError extends ABACError { readonly policyId: string | undefined; readonly requestId: string | undefined; constructor(message: string, context?: Record); static invalidCondition(condition: unknown, policyId?: string): EvaluationError; static unknownOperator(operator: string, policyId?: string): EvaluationError; static invalidOperatorArity(operator: string, expected: number | string, actual: number, policyId?: string): EvaluationError; static functionError(functionName: string, reason: string, policyId?: string): EvaluationError; } /** * Thrown when attribute resolution fails */ export declare class AttributeResolutionError extends ABACError { readonly category: string; readonly entityId: string; readonly providerName: string | undefined; constructor(message: string, category: string, entityId: string, providerName?: string, cause?: Error); static providerError(category: string, entityId: string, providerName: string, cause: Error): AttributeResolutionError; static notInitialized(providerName: string): AttributeResolutionError; } /** * Thrown when a required policy is not found */ export declare class PolicyNotFoundError extends ABACError { readonly policyId: string; constructor(policyId: string, context?: Record); } /** * Thrown when combining algorithm operations fail */ export declare class CombiningAlgorithmError extends ABACError { readonly algorithm: string; constructor(message: string, algorithm: string, context?: Record); static unknownAlgorithm(algorithm: string): CombiningAlgorithmError; static evaluationFailed(algorithm: string, reason: string): CombiningAlgorithmError; } /** * Thrown when request validation fails */ export declare class RequestValidationError extends ABACError { readonly field: string; constructor(field: string, message: string); static missingField(field: string): RequestValidationError; static invalidField(field: string, reason: string): RequestValidationError; } /** * Thrown when policy storage operations fail */ export declare class PolicyStorageError extends ABACError { readonly operation: 'save' | 'load' | 'delete' | 'list'; readonly policyId: string | undefined; constructor(operation: 'save' | 'load' | 'delete' | 'list', message: string, policyId?: string, cause?: Error); static loadFailed(source: string, cause?: Error): PolicyStorageError; static saveFailed(policyId: string, cause?: Error): PolicyStorageError; static deleteFailed(policyId: string, cause?: Error): PolicyStorageError; } /** * Type guard to check if an error is an ABACError */ export declare function isABACError(error: unknown): error is ABACError; /** * Wraps unknown errors into ABACError instances */ export declare function wrapError(error: unknown, defaultMessage?: string): ABACError; /** * Safely extracts error message from unknown error */ export declare function getErrorMessage(error: unknown): string; /** * Creates a user-friendly error message from ABACError */ export declare function formatErrorForUser(error: ABACError): string; //# sourceMappingURL=errors.d.ts.map