From 92340bbc338c234d2add6cf6d768f560399c9731 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Tue, 31 Mar 2020 16:28:35 +0200 Subject: [PATCH] Improve error messages format --- src/controllers/UserWebSocketController.ts | 5 ++++- src/entities/WebSocketRequestHandler.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/controllers/UserWebSocketController.ts b/src/controllers/UserWebSocketController.ts index 43b0c32..e49b515 100644 --- a/src/controllers/UserWebSocketController.ts +++ b/src/controllers/UserWebSocketController.ts @@ -175,7 +175,10 @@ export class UserWebSocketController { // Try again to send again a response try { - handler.sendResponse("error", "Server error."); + handler.sendResponse("error", { + code: 500, + message: "Server error" + }); } catch(e) { console.error(e); } diff --git a/src/entities/WebSocketRequestHandler.ts b/src/entities/WebSocketRequestHandler.ts index 43e4f0a..9bff22b 100644 --- a/src/entities/WebSocketRequestHandler.ts +++ b/src/entities/WebSocketRequestHandler.ts @@ -30,7 +30,10 @@ export class UserWebSocketRequestsHandler extends BaseRequestsHandler { } public error(code: number, message: string): void { - this.sendResponse("error", code + " - " + message); + this.sendResponse("error", { + code: code, + message: message + }); throw new Error("An error occured while processing user WS request!"); }