@eventmsg/core
Version:
EventMsgV3 TypeScript library - Core protocol implementation with transport abstraction
1 lines • 4.12 kB
Source Map (JSON)
{"version":3,"file":"timeout-error.cjs","names":["EventMsgError"],"sources":["../../src/errors/timeout-error.ts"],"sourcesContent":["import { EventMsgError } from \"./event-msg-error.js\";\n\n/**\n * Error for operations that exceed their timeout duration\n */\nexport class TimeoutError extends EventMsgError {\n /** Timeout duration in milliseconds */\n readonly timeoutMs: number;\n\n /** Operation that timed out */\n readonly operation: string;\n\n constructor(\n message: string,\n timeoutMs: number,\n operation = \"operation\",\n options: {\n context?: Record<string, unknown>;\n solutions?: string[];\n cause?: Error;\n } = {}\n ) {\n super(message, \"TIMEOUT_ERROR\", {\n ...options,\n context: {\n ...options.context,\n timeoutMs,\n operation,\n },\n solutions: [\n \"Increase timeout duration\",\n \"Check network connectivity\",\n \"Verify target device is responding\",\n \"Reduce message frequency\",\n ],\n });\n\n this.timeoutMs = timeoutMs;\n this.operation = operation;\n }\n}\n\n/**\n * Send operation timed out\n */\nexport class SendTimeoutError extends TimeoutError {\n constructor(\n timeoutMs: number,\n options: {\n context?: Record<string, unknown>;\n cause?: Error;\n } = {}\n ) {\n super(`Send operation timed out after ${timeoutMs}ms`, timeoutMs, \"send\", {\n ...options,\n solutions: [\n \"Increase send timeout\",\n \"Check transport connection\",\n \"Verify target device is reachable\",\n \"Check for network congestion\",\n ],\n });\n\n this.code = \"SEND_TIMEOUT_ERROR\";\n }\n}\n\n/**\n * WaitFor operation timed out\n */\nexport class WaitForTimeoutError extends TimeoutError {\n /** Event name that was being waited for */\n readonly eventName: string;\n\n constructor(\n eventName: string,\n timeoutMs: number,\n options: {\n context?: Record<string, unknown>;\n cause?: Error;\n } = {}\n ) {\n super(\n `waitFor('${eventName}') timed out after ${timeoutMs}ms`,\n timeoutMs,\n \"waitFor\",\n {\n ...options,\n context: {\n ...options.context,\n eventName,\n },\n solutions: [\n \"Increase waitFor timeout\",\n \"Check if event name is correct\",\n \"Verify sender is responding\",\n \"Check event filter conditions\",\n ],\n }\n );\n\n this.eventName = eventName;\n this.code = \"WAIT_FOR_TIMEOUT_ERROR\";\n }\n}\n\n/**\n * Connection timeout error\n */\nexport class ConnectionTimeoutError extends TimeoutError {\n constructor(\n timeoutMs: number,\n options: {\n context?: Record<string, unknown>;\n cause?: Error;\n } = {}\n ) {\n super(\n `Connection attempt timed out after ${timeoutMs}ms`,\n timeoutMs,\n \"connect\",\n {\n ...options,\n solutions: [\n \"Increase connection timeout\",\n \"Check device availability\",\n \"Verify connection parameters\",\n \"Check for interference\",\n ],\n }\n );\n\n this.code = \"CONNECTION_TIMEOUT_ERROR\";\n }\n}\n"],"mappings":";;;;;;AAKA,IAAa,eAAb,cAAkCA,sCAAc;;CAE9C,AAAS;;CAGT,AAAS;CAET,YACE,SACA,WACA,YAAY,aACZ,UAII,EAAE,EACN;AACA,QAAM,SAAS,iBAAiB;GAC9B,GAAG;GACH,SAAS;IACP,GAAG,QAAQ;IACX;IACA;IACD;GACD,WAAW;IACT;IACA;IACA;IACA;IACD;GACF,CAAC;AAEF,OAAK,YAAY;AACjB,OAAK,YAAY;;;;;;AAOrB,IAAa,mBAAb,cAAsC,aAAa;CACjD,YACE,WACA,UAGI,EAAE,EACN;AACA,QAAM,kCAAkC,UAAU,KAAK,WAAW,QAAQ;GACxE,GAAG;GACH,WAAW;IACT;IACA;IACA;IACA;IACD;GACF,CAAC;AAEF,OAAK,OAAO;;;;;;AAOhB,IAAa,sBAAb,cAAyC,aAAa;;CAEpD,AAAS;CAET,YACE,WACA,WACA,UAGI,EAAE,EACN;AACA,QACE,YAAY,UAAU,qBAAqB,UAAU,KACrD,WACA,WACA;GACE,GAAG;GACH,SAAS;IACP,GAAG,QAAQ;IACX;IACD;GACD,WAAW;IACT;IACA;IACA;IACA;IACD;GACF,CACF;AAED,OAAK,YAAY;AACjB,OAAK,OAAO;;;;;;AAOhB,IAAa,yBAAb,cAA4C,aAAa;CACvD,YACE,WACA,UAGI,EAAE,EACN;AACA,QACE,sCAAsC,UAAU,KAChD,WACA,WACA;GACE,GAAG;GACH,WAAW;IACT;IACA;IACA;IACA;IACD;GACF,CACF;AAED,OAAK,OAAO"}