diff --git a/src/websocket.ts b/src/websocket.ts index eb4a71f..658a67b 100644 --- a/src/websocket.ts +++ b/src/websocket.ts @@ -72,8 +72,17 @@ export class WebsocketConnectionManager { } } - const answer = (id: string, data: any, error: boolean = false) => { - if (error) Logging.error(error as any); + const answer = (id: string, data: any, err?: Error | string) => { + let error = false; + if (err) { + if (err instanceof Error) { + data = err.message; + } else { + data = err; + } + + error = true; + } socket.send( JSON.stringify({ ns: "message", data: { id, error, data } }) );