@sailboat-computer/event-bus
Version:
Standardized event bus for sailboat computer v3 with resilience features and offline capabilities
191 lines • 5.62 kB
JavaScript
;
/**
* Event bus error types
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.NotInitializedError = exports.ConfigurationError = exports.SubscribeError = exports.PublishError = exports.ConnectionError = exports.EventBusErrorCode = exports.EventBusError = void 0;
/**
* Base error class for event bus errors
*/
class EventBusError extends Error {
/**
* Create a new event bus error
*
* @param code - Error code
* @param message - Error message
* @param details - Error details
*/
constructor(code, message, details) {
super(message);
this.name = 'EventBusError';
this.code = code;
this.details = details || undefined;
// Ensure proper prototype chain for instanceof checks
Object.setPrototypeOf(this, EventBusError.prototype);
}
}
exports.EventBusError = EventBusError;
/**
* Error codes for event bus errors
*/
var EventBusErrorCode;
(function (EventBusErrorCode) {
/**
* Initialization error
*/
EventBusErrorCode["INITIALIZATION_FAILED"] = "INITIALIZATION_FAILED";
/**
* Connection error
*/
EventBusErrorCode["CONNECTION_FAILED"] = "CONNECTION_FAILED";
/**
* Publish error
*/
EventBusErrorCode["PUBLISH_FAILED"] = "PUBLISH_FAILED";
/**
* Subscribe error
*/
EventBusErrorCode["SUBSCRIBE_FAILED"] = "SUBSCRIBE_FAILED";
/**
* Acknowledgment error
*/
EventBusErrorCode["ACKNOWLEDGE_FAILED"] = "ACKNOWLEDGE_FAILED";
/**
* Configuration error
*/
EventBusErrorCode["INVALID_CONFIGURATION"] = "INVALID_CONFIGURATION";
/**
* Adapter error
*/
EventBusErrorCode["ADAPTER_ERROR"] = "ADAPTER_ERROR";
/**
* Timeout error
*/
EventBusErrorCode["TIMEOUT"] = "TIMEOUT";
/**
* Not initialized error
*/
EventBusErrorCode["NOT_INITIALIZED"] = "NOT_INITIALIZED";
/**
* Already initialized error
*/
EventBusErrorCode["ALREADY_INITIALIZED"] = "ALREADY_INITIALIZED";
/**
* Already closed error
*/
EventBusErrorCode["ALREADY_CLOSED"] = "ALREADY_CLOSED";
/**
* Invalid event type error
*/
EventBusErrorCode["INVALID_EVENT_TYPE"] = "INVALID_EVENT_TYPE";
/**
* Invalid event data error
*/
EventBusErrorCode["INVALID_EVENT_DATA"] = "INVALID_EVENT_DATA";
/**
* Invalid subscription error
*/
EventBusErrorCode["INVALID_SUBSCRIPTION"] = "INVALID_SUBSCRIPTION";
/**
* Buffer full error
*/
EventBusErrorCode["BUFFER_FULL"] = "BUFFER_FULL";
/**
* Event not found error
*/
EventBusErrorCode["EVENT_NOT_FOUND"] = "EVENT_NOT_FOUND";
/**
* Unknown error
*/
EventBusErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
})(EventBusErrorCode || (exports.EventBusErrorCode = EventBusErrorCode = {}));
/**
* Connection error class
*/
class ConnectionError extends EventBusError {
/**
* Create a new connection error
*
* @param message - Error message
* @param details - Error details
*/
constructor(message, details) {
super(EventBusErrorCode.CONNECTION_FAILED, message, details);
this.name = 'ConnectionError';
// Ensure proper prototype chain for instanceof checks
Object.setPrototypeOf(this, ConnectionError.prototype);
}
}
exports.ConnectionError = ConnectionError;
/**
* Publish error class
*/
class PublishError extends EventBusError {
/**
* Create a new publish error
*
* @param message - Error message
* @param details - Error details
*/
constructor(message, details) {
super(EventBusErrorCode.PUBLISH_FAILED, message, details);
this.name = 'PublishError';
// Ensure proper prototype chain for instanceof checks
Object.setPrototypeOf(this, PublishError.prototype);
}
}
exports.PublishError = PublishError;
/**
* Subscribe error class
*/
class SubscribeError extends EventBusError {
/**
* Create a new subscribe error
*
* @param message - Error message
* @param details - Error details
*/
constructor(message, details) {
super(EventBusErrorCode.SUBSCRIBE_FAILED, message, details);
this.name = 'SubscribeError';
// Ensure proper prototype chain for instanceof checks
Object.setPrototypeOf(this, SubscribeError.prototype);
}
}
exports.SubscribeError = SubscribeError;
/**
* Configuration error class
*/
class ConfigurationError extends EventBusError {
/**
* Create a new configuration error
*
* @param message - Error message
* @param details - Error details
*/
constructor(message, details) {
super(EventBusErrorCode.INVALID_CONFIGURATION, message, details);
this.name = 'ConfigurationError';
// Ensure proper prototype chain for instanceof checks
Object.setPrototypeOf(this, ConfigurationError.prototype);
}
}
exports.ConfigurationError = ConfigurationError;
/**
* Not initialized error class
*/
class NotInitializedError extends EventBusError {
/**
* Create a new not initialized error
*
* @param message - Error message
*/
constructor(message = 'Event bus not initialized') {
super(EventBusErrorCode.NOT_INITIALIZED, message);
this.name = 'NotInitializedError';
// Ensure proper prototype chain for instanceof checks
Object.setPrototypeOf(this, NotInitializedError.prototype);
}
}
exports.NotInitializedError = NotInitializedError;
//# sourceMappingURL=errors.js.map