@eventmsg/core
Version:
EventMsgV3 TypeScript library - Core protocol implementation with transport abstraction
95 lines (93 loc) • 2.49 kB
JavaScript
const require_event_msg_error = require('./event-msg-error.cjs');
//#region src/errors/timeout-error.ts
/**
* Error for operations that exceed their timeout duration
*/
var TimeoutError = class extends require_event_msg_error.EventMsgError {
/** Timeout duration in milliseconds */
timeoutMs;
/** Operation that timed out */
operation;
constructor(message, timeoutMs, operation = "operation", options = {}) {
super(message, "TIMEOUT_ERROR", {
...options,
context: {
...options.context,
timeoutMs,
operation
},
solutions: [
"Increase timeout duration",
"Check network connectivity",
"Verify target device is responding",
"Reduce message frequency"
]
});
this.timeoutMs = timeoutMs;
this.operation = operation;
}
};
/**
* Send operation timed out
*/
var SendTimeoutError = class extends TimeoutError {
constructor(timeoutMs, options = {}) {
super(`Send operation timed out after ${timeoutMs}ms`, timeoutMs, "send", {
...options,
solutions: [
"Increase send timeout",
"Check transport connection",
"Verify target device is reachable",
"Check for network congestion"
]
});
this.code = "SEND_TIMEOUT_ERROR";
}
};
/**
* WaitFor operation timed out
*/
var WaitForTimeoutError = class extends TimeoutError {
/** Event name that was being waited for */
eventName;
constructor(eventName, timeoutMs, options = {}) {
super(`waitFor('${eventName}') timed out after ${timeoutMs}ms`, timeoutMs, "waitFor", {
...options,
context: {
...options.context,
eventName
},
solutions: [
"Increase waitFor timeout",
"Check if event name is correct",
"Verify sender is responding",
"Check event filter conditions"
]
});
this.eventName = eventName;
this.code = "WAIT_FOR_TIMEOUT_ERROR";
}
};
/**
* Connection timeout error
*/
var ConnectionTimeoutError = class extends TimeoutError {
constructor(timeoutMs, options = {}) {
super(`Connection attempt timed out after ${timeoutMs}ms`, timeoutMs, "connect", {
...options,
solutions: [
"Increase connection timeout",
"Check device availability",
"Verify connection parameters",
"Check for interference"
]
});
this.code = "CONNECTION_TIMEOUT_ERROR";
}
};
//#endregion
exports.ConnectionTimeoutError = ConnectionTimeoutError;
exports.SendTimeoutError = SendTimeoutError;
exports.TimeoutError = TimeoutError;
exports.WaitForTimeoutError = WaitForTimeoutError;
//# sourceMappingURL=timeout-error.cjs.map