/** * Union of all possible errors in the enforce-layers system. */ export type LayerError = ConfigError | DiscoveryError; /** * Errors that can occur during configuration loading and validation. */ export type ConfigError = { type: 'config-not-found'; message: string; path: string; } | { type: 'config-read-error'; message: string; path: string; cause?: unknown; } | { type: 'config-parse-error'; message: string; path: string; cause?: unknown; } | { type: 'config-validation-error'; message: string; details?: string[]; }; /** * Errors that can occur during package discovery. */ export type DiscoveryError = { type: 'glob-failed'; message: string; pattern: string; cause?: unknown; } | { type: 'package-parse-error'; message: string; path: string; cause?: unknown; }; /** * Error type for all possible stratify error scenarios. */ export type StratifyErrorType = LayerError['type']; /** * Public error class thrown by the stratifyjs API on infrastructure failures * (config loading, parsing, validation, package discovery). * * Consumers catch this in a standard try/catch: * try { * const result = await validateLayers(); * } catch (e) { * if (e instanceof StratifyError) { * console.error(e.type, e.message); * } * } */ export declare class StratifyError extends Error { readonly type: StratifyErrorType; readonly details?: string[]; readonly cause?: unknown; constructor(layerError: LayerError); } /** * Format any LayerError into a human-readable string. */ export declare function formatLayerError(error: LayerError): string;