@eventmsg/core
Version:
EventMsgV3 TypeScript library - Core protocol implementation with transport abstraction
1 lines • 3.13 kB
Source Map (JSON)
{"version":3,"file":"transport-error.cjs","names":["EventMsgError"],"sources":["../../src/errors/transport-error.ts"],"sourcesContent":["import { EventMsgError } from \"./event-msg-error.js\";\n\n/**\n * Error related to transport layer operations (connection, sending, receiving)\n */\nexport class TransportError extends EventMsgError {\n constructor(\n message: string,\n options: {\n context?: Record<string, unknown>;\n solutions?: string[];\n cause?: Error;\n } = {}\n ) {\n super(message, \"TRANSPORT_ERROR\", {\n ...options,\n solutions: options.solutions || [\n \"Check transport connection\",\n \"Verify transport configuration\",\n \"Retry the operation\",\n ],\n });\n }\n}\n\n/**\n * Transport connection failed\n */\nexport class ConnectionError extends TransportError {\n constructor(\n message = \"Failed to connect to transport\",\n options: {\n context?: Record<string, unknown>;\n cause?: Error;\n } = {}\n ) {\n super(message, {\n ...options,\n solutions: [\n \"Check if the device is available\",\n \"Verify connection parameters\",\n \"Ensure no other process is using the transport\",\n \"Check device permissions\",\n ],\n });\n\n this.code = \"CONNECTION_ERROR\";\n }\n}\n\n/**\n * Transport send operation failed\n */\nexport class SendError extends TransportError {\n constructor(\n message = \"Failed to send data through transport\",\n options: {\n context?: Record<string, unknown>;\n cause?: Error;\n } = {}\n ) {\n super(message, {\n ...options,\n solutions: [\n \"Check transport connection status\",\n \"Verify message size is within limits\",\n \"Retry sending the message\",\n \"Check for transport buffer overflow\",\n ],\n });\n\n this.code = \"SEND_ERROR\";\n }\n}\n\n/**\n * Transport disconnection error\n */\nexport class DisconnectionError extends TransportError {\n constructor(\n message = \"Transport disconnected unexpectedly\",\n options: {\n context?: Record<string, unknown>;\n cause?: Error;\n } = {}\n ) {\n super(message, {\n ...options,\n solutions: [\n \"Check physical connection\",\n \"Implement reconnection logic\",\n \"Monitor connection status\",\n \"Handle graceful disconnection\",\n ],\n });\n\n this.code = \"DISCONNECTION_ERROR\";\n }\n}\n"],"mappings":";;;;;;AAKA,IAAa,iBAAb,cAAoCA,sCAAc;CAChD,YACE,SACA,UAII,EAAE,EACN;AACA,QAAM,SAAS,mBAAmB;GAChC,GAAG;GACH,WAAW,QAAQ,aAAa;IAC9B;IACA;IACA;IACD;GACF,CAAC;;;;;;AAON,IAAa,kBAAb,cAAqC,eAAe;CAClD,YACE,UAAU,kCACV,UAGI,EAAE,EACN;AACA,QAAM,SAAS;GACb,GAAG;GACH,WAAW;IACT;IACA;IACA;IACA;IACD;GACF,CAAC;AAEF,OAAK,OAAO;;;;;;AAOhB,IAAa,YAAb,cAA+B,eAAe;CAC5C,YACE,UAAU,yCACV,UAGI,EAAE,EACN;AACA,QAAM,SAAS;GACb,GAAG;GACH,WAAW;IACT;IACA;IACA;IACA;IACD;GACF,CAAC;AAEF,OAAK,OAAO;;;;;;AAOhB,IAAa,qBAAb,cAAwC,eAAe;CACrD,YACE,UAAU,uCACV,UAGI,EAAE,EACN;AACA,QAAM,SAAS;GACb,GAAG;GACH,WAAW;IACT;IACA;IACA;IACA;IACD;GACF,CAAC;AAEF,OAAK,OAAO"}