UNPKG

hook-engine

Version:

Production-grade webhook engine with comprehensive adapter support, security, reliability, structured logging, and CLI tools.

63 lines (62 loc) 1.89 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TimeoutError = exports.NetworkError = exports.ConfigurationError = exports.HookEngineError = void 0; /** * Base error class for all hook-engine errors */ class HookEngineError extends Error { constructor(message, code, context = {}, retryable = false) { super(message); this.name = this.constructor.name; this.code = code; this.context = context; this.retryable = retryable; this.timestamp = new Date(); // Maintains proper stack trace for where our error was thrown (only available on V8) if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } } /** * Serialize error for logging/debugging */ toJSON() { return { name: this.name, message: this.message, code: this.code, context: this.context, retryable: this.retryable, timestamp: this.timestamp.toISOString(), stack: this.stack }; } } exports.HookEngineError = HookEngineError; /** * Configuration-related errors */ class ConfigurationError extends HookEngineError { constructor(message, context = {}) { super(message, 'CONFIGURATION_ERROR', context, false); } } exports.ConfigurationError = ConfigurationError; /** * Network-related errors that might be retryable */ class NetworkError extends HookEngineError { constructor(message, context = {}, retryable = true) { super(message, 'NETWORK_ERROR', context, retryable); } } exports.NetworkError = NetworkError; /** * Timeout errors */ class TimeoutError extends HookEngineError { constructor(message, context = {}) { super(message, 'TIMEOUT_ERROR', context, true); } } exports.TimeoutError = TimeoutError;