Better error handling
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Fabian Stamm 2020-10-28 01:41:31 +01:00
parent ff468410ad
commit 24e46922c9

View File

@ -72,8 +72,17 @@ export class WebsocketConnectionManager {
} }
} }
const answer = (id: string, data: any, error: boolean = false) => { const answer = (id: string, data: any, err?: Error | string) => {
if (error) Logging.error(error as any); let error = false;
if (err) {
if (err instanceof Error) {
data = err.message;
} else {
data = err;
}
error = true;
}
socket.send( socket.send(
JSON.stringify({ ns: "message", data: { id, error, data } }) JSON.stringify({ ns: "message", data: { id, error, data } })
); );