kist
Version:
Lightweight Package Pipeline Processor with Plugin Architecture
174 lines • 6.37 kB
JavaScript
export class KistError extends Error {
constructor(message, code, context, cause) {
super(message);
this.name = "KistError";
this.code = code;
this.context = context;
this.cause = cause;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
}
}
toJSON() {
var _a;
return {
name: this.name,
message: this.message,
code: this.code,
context: this.context,
stack: this.stack,
cause: (_a = this.cause) === null || _a === void 0 ? void 0 : _a.message,
};
}
}
export class ConfigError extends KistError {
constructor(message, context, cause) {
super(message, "CONFIG_ERROR", context, cause);
this.name = "ConfigError";
}
}
export class ConfigNotFoundError extends ConfigError {
constructor(configPath, cause) {
super(`Configuration file not found: ${configPath}`, { configPath }, cause);
this.name = "ConfigNotFoundError";
}
}
export class ConfigParseError extends ConfigError {
constructor(configPath, parseError, cause) {
super(`Failed to parse configuration: ${parseError}`, { configPath, parseError }, cause);
this.name = "ConfigParseError";
}
}
export class ConfigValidationError extends ConfigError {
constructor(validationErrors, configPath, cause) {
super(`Configuration validation failed:\n - ${validationErrors.join("\n - ")}`, { configPath, validationErrors }, cause);
this.name = "ConfigValidationError";
this.validationErrors = validationErrors;
}
}
export class BuildError extends KistError {
constructor(message, context, cause) {
super(message, "BUILD_ERROR", context, cause);
this.name = "BuildError";
}
}
export class ActionError extends BuildError {
constructor(actionName, message, context, cause) {
super(`Action "${actionName}" failed: ${message}`, Object.assign({ actionName }, context), cause);
this.name = "ActionError";
}
}
export class StepError extends BuildError {
constructor(stepName, stageName, message, cause) {
super(`Step "${stepName}" in stage "${stageName}" failed: ${message}`, { stepName, stageName }, cause);
this.name = "StepError";
}
}
export class StageError extends BuildError {
constructor(stageName, message, cause) {
super(`Stage "${stageName}" failed: ${message}`, { stageName }, cause);
this.name = "StageError";
}
}
export class PluginError extends KistError {
constructor(message, context, cause) {
super(message, "PLUGIN_ERROR", context, cause);
this.name = "PluginError";
}
}
export class PluginNotFoundError extends PluginError {
constructor(pluginName, cause) {
super(`Plugin not found: ${pluginName}`, { pluginName }, cause);
this.name = "PluginNotFoundError";
}
}
export class PluginInitError extends PluginError {
constructor(pluginName, message, cause) {
super(`Failed to initialize plugin "${pluginName}": ${message}`, { pluginName }, cause);
this.name = "PluginInitError";
}
}
export class FileSystemError extends KistError {
constructor(message, context, cause) {
super(message, "FS_ERROR", context, cause);
this.name = "FileSystemError";
}
}
export class FileNotFoundError extends FileSystemError {
constructor(filePath, cause) {
super(`File not found: ${filePath}`, { filePath }, cause);
this.name = "FileNotFoundError";
}
}
export class DirectoryNotFoundError extends FileSystemError {
constructor(dirPath, cause) {
super(`Directory not found: ${dirPath}`, { dirPath }, cause);
this.name = "DirectoryNotFoundError";
}
}
export class PermissionError extends FileSystemError {
constructor(path, operation, cause) {
super(`Permission denied: cannot ${operation} "${path}"`, { path, operation }, cause);
this.name = "PermissionError";
}
}
export class PathTraversalError extends FileSystemError {
constructor(path, basePath) {
super(`Path traversal detected: "${path}" escapes base path "${basePath}"`, { path, basePath });
this.name = "PathTraversalError";
}
}
export class CLIError extends KistError {
constructor(message, context, cause) {
super(message, "CLI_ERROR", context, cause);
this.name = "CLIError";
}
}
export class InvalidArgumentError extends CLIError {
constructor(argument, reason) {
super(`Invalid argument "${argument}": ${reason}`, { argument, reason });
this.name = "InvalidArgumentError";
}
}
export class MissingArgumentError extends CLIError {
constructor(argument) {
super(`Missing required argument: ${argument}`, { argument });
this.name = "MissingArgumentError";
}
}
export class TimeoutError extends KistError {
constructor(operation, timeoutMs, cause) {
super(`Operation "${operation}" timed out after ${timeoutMs}ms`, "TIMEOUT_ERROR", { operation, timeoutMs }, cause);
this.name = "TimeoutError";
}
}
export class ResourceLimitError extends KistError {
constructor(resource, limit, actual, unit = "") {
super(`Resource limit exceeded: ${resource} (limit: ${limit}${unit}, actual: ${actual}${unit})`, "RESOURCE_LIMIT_ERROR", { resource, limit, actual, unit });
this.name = "ResourceLimitError";
}
}
export const ErrorCodes = {
CONFIG_ERROR: "CONFIG_ERROR",
CONFIG_NOT_FOUND: "CONFIG_NOT_FOUND",
CONFIG_PARSE_ERROR: "CONFIG_PARSE_ERROR",
CONFIG_VALIDATION_ERROR: "CONFIG_VALIDATION_ERROR",
BUILD_ERROR: "BUILD_ERROR",
ACTION_ERROR: "ACTION_ERROR",
STEP_ERROR: "STEP_ERROR",
STAGE_ERROR: "STAGE_ERROR",
PLUGIN_ERROR: "PLUGIN_ERROR",
PLUGIN_NOT_FOUND: "PLUGIN_NOT_FOUND",
PLUGIN_INIT_ERROR: "PLUGIN_INIT_ERROR",
FS_ERROR: "FS_ERROR",
FILE_NOT_FOUND: "FILE_NOT_FOUND",
DIR_NOT_FOUND: "DIR_NOT_FOUND",
PERMISSION_ERROR: "PERMISSION_ERROR",
PATH_TRAVERSAL: "PATH_TRAVERSAL",
CLI_ERROR: "CLI_ERROR",
INVALID_ARGUMENT: "INVALID_ARGUMENT",
MISSING_ARGUMENT: "MISSING_ARGUMENT",
TIMEOUT_ERROR: "TIMEOUT_ERROR",
RESOURCE_LIMIT_ERROR: "RESOURCE_LIMIT_ERROR",
};
//# sourceMappingURL=index.js.map