UNPKG

@eventmsg/core

Version:

EventMsgV3 TypeScript library - Core protocol implementation with transport abstraction

90 lines (88 loc) 2.31 kB
import { EventMsgError } from "./event-msg-error.js"; //#region src/errors/protocol-error.ts /** * Error related to EventMsgV3 protocol operations (encoding, decoding, validation) */ var ProtocolError = class extends EventMsgError { constructor(message, options = {}) { super(message, "PROTOCOL_ERROR", { ...options, solutions: options.solutions || [ "Check message format", "Verify protocol specification compliance", "Review message content" ] }); } }; /** * Message encoding failed */ var EncodingError = class extends ProtocolError { constructor(message = "Failed to encode message", options = {}) { super(message, { ...options, solutions: [ "Check event name length (≤64 bytes)", "Check event data length (≤3048 bytes)", "Verify data is JSON serializable", "Check for invalid characters" ] }); this.code = "ENCODING_ERROR"; } }; /** * Message decoding failed */ var DecodingError = class extends ProtocolError { constructor(message = "Failed to decode message", options = {}) { super(message, { ...options, solutions: [ "Check message framing (SOH, STX, US, EOT)", "Verify byte stuffing is correct", "Check for data corruption", "Ensure sender uses same protocol version" ] }); this.code = "DECODING_ERROR"; } }; /** * Message validation failed */ var ValidationError = class extends ProtocolError { constructor(message = "Message validation failed", options = {}) { super(message, { ...options, solutions: [ "Check address ranges (0-255)", "Verify message size limits", "Check required fields are present", "Validate data types" ] }); this.code = "VALIDATION_ERROR"; } }; /** * Invalid message format */ var InvalidMessageError = class extends ProtocolError { constructor(message = "Invalid message format", options = {}) { super(message, { ...options, solutions: [ "Check message starts with SOH (0x01)", "Check message ends with EOT (0x04)", "Verify minimum message length (10 bytes)", "Check header is exactly 7 bytes after unstuffing" ] }); this.code = "INVALID_MESSAGE_ERROR"; } }; //#endregion export { DecodingError, EncodingError, InvalidMessageError, ProtocolError, ValidationError }; //# sourceMappingURL=protocol-error.js.map