UNPKG

@notjustcoders/ioc-arise

Version:

Arise type-safe IoC containers from your code. Zero overhead, zero coupling.

80 lines 3.27 kB
"use strict"; /** * IoC Arise CLI Error System * * This module provides a comprehensive error handling system with: * - Custom error codes for different error categories * - Structured error classes with context and suggestions * - Factory functions for creating specific errors * - Consistent error formatting and logging */ Object.defineProperty(exports, "__esModule", { value: true }); exports.ErrorUtils = exports.ErrorFactory = exports.FileSystemError = exports.ValidationError = exports.GenerationError = exports.AnalysisError = exports.ConfigError = exports.ErrorSeverity = exports.IoCErrorCode = exports.IoCError = void 0; const IoCError_js_1 = require("./IoCError.js"); var IoCError_js_2 = require("./IoCError.js"); Object.defineProperty(exports, "IoCError", { enumerable: true, get: function () { return IoCError_js_2.IoCError; } }); Object.defineProperty(exports, "IoCErrorCode", { enumerable: true, get: function () { return IoCError_js_2.IoCErrorCode; } }); Object.defineProperty(exports, "ErrorSeverity", { enumerable: true, get: function () { return IoCError_js_2.ErrorSeverity; } }); Object.defineProperty(exports, "ConfigError", { enumerable: true, get: function () { return IoCError_js_2.ConfigError; } }); Object.defineProperty(exports, "AnalysisError", { enumerable: true, get: function () { return IoCError_js_2.AnalysisError; } }); Object.defineProperty(exports, "GenerationError", { enumerable: true, get: function () { return IoCError_js_2.GenerationError; } }); Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return IoCError_js_2.ValidationError; } }); Object.defineProperty(exports, "FileSystemError", { enumerable: true, get: function () { return IoCError_js_2.FileSystemError; } }); var errorFactory_js_1 = require("./errorFactory.js"); Object.defineProperty(exports, "ErrorFactory", { enumerable: true, get: function () { return errorFactory_js_1.ErrorFactory; } }); /** * Utility functions for error handling */ class ErrorUtils { /** * Check if an error is an IoC error */ static isIoCError(error) { return error instanceof ErrorUtils.IoCError; } /** * Get error code from any error */ static getErrorCode(error) { if (ErrorUtils.isIoCError(error)) { return error.code; } return undefined; } /** * Format error for console output */ static formatForConsole(error) { if (ErrorUtils.isIoCError(error)) { return error.getFormattedMessage(); } return error.message || String(error); } /** * Extract stack trace from error */ static getStackTrace(error) { return error.stack; } /** * Check if error is critical */ static isCritical(error) { if (ErrorUtils.isIoCError(error)) { return error.severity === 'critical'; } return false; } /** * Get suggestions from error */ static getSuggestions(error) { if (ErrorUtils.isIoCError(error)) { return error.suggestions || []; } return []; } } exports.ErrorUtils = ErrorUtils; ErrorUtils.IoCError = IoCError_js_1.IoCError; //# sourceMappingURL=index.js.map