@clipwhisperer/common
Version:
ClipWhisperer Common - Shared library providing core utilities, database schemas, authentication, bucket management, and common functionality across all ClipWhisperer microservices
63 lines (62 loc) • 2.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigurationError = exports.ProcessError = exports.HealthCheckError = exports.DependencyError = exports.ServiceError = exports.ServiceStatus = void 0;
/**
* Represents the current status of a service
*/
var ServiceStatus;
(function (ServiceStatus) {
ServiceStatus["STOPPED"] = "stopped";
ServiceStatus["STARTING"] = "starting";
ServiceStatus["RUNNING"] = "running";
ServiceStatus["STOPPING"] = "stopping";
ServiceStatus["UNHEALTHY"] = "unhealthy";
ServiceStatus["FAILED"] = "failed";
ServiceStatus["UNKNOWN"] = "unknown";
})(ServiceStatus || (exports.ServiceStatus = ServiceStatus = {}));
/**
* Error types for better error handling
*/
class ServiceError extends Error {
constructor(message, serviceName, code, cause) {
super(message);
this.serviceName = serviceName;
this.code = code;
this.cause = cause;
this.name = 'ServiceError';
}
}
exports.ServiceError = ServiceError;
class DependencyError extends ServiceError {
constructor(message, serviceName, dependency, cause) {
super(message, serviceName, 'DEPENDENCY_ERROR', cause);
this.dependency = dependency;
this.name = 'DependencyError';
}
}
exports.DependencyError = DependencyError;
class HealthCheckError extends ServiceError {
constructor(message, serviceName, endpoint, cause) {
super(message, serviceName, 'HEALTH_CHECK_ERROR', cause);
this.endpoint = endpoint;
this.name = 'HealthCheckError';
}
}
exports.HealthCheckError = HealthCheckError;
class ProcessError extends ServiceError {
constructor(message, serviceName, pid, cause) {
super(message, serviceName, 'PROCESS_ERROR', cause);
this.pid = pid;
this.name = 'ProcessError';
}
}
exports.ProcessError = ProcessError;
class ConfigurationError extends Error {
constructor(message, configKey, cause) {
super(message);
this.configKey = configKey;
this.cause = cause;
this.name = 'ConfigurationError';
}
}
exports.ConfigurationError = ConfigurationError;