UNPKG

read-config-ng

Version:
44 lines 1.36 kB
/** * Custom error class for read-config-ng */ export class ReadConfigError extends Error { code; path; cause; constructor(message, code = 'READ_CONFIG_ERROR', path, cause) { super(message); this.name = 'ReadConfigError'; this.code = code; this.path = path; this.cause = cause; // Maintains proper stack trace for where our error was thrown (only available on V8) if (Error.captureStackTrace) { Error.captureStackTrace(this, ReadConfigError); } } /** * Create a file not found error */ static fileNotFound(path) { return new ReadConfigError(`Configuration file not found: ${path}`, 'FILE_NOT_FOUND', path); } /** * Create a parse error */ static parseError(path, cause) { return new ReadConfigError(`Failed to parse configuration file: ${path}`, 'PARSE_ERROR', path, cause); } /** * Create a validation error */ static validationError(message) { return new ReadConfigError(message, 'VALIDATION_ERROR'); } /** * Create a variable resolution error */ static resolutionError(variable, type) { return new ReadConfigError(`Could not resolve ${type} variable: ${variable}`, 'RESOLUTION_ERROR'); } } //# sourceMappingURL=read-config-error.js.map