1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-22 05:19:22 +00:00

Improve errors handling

This commit is contained in:
Pierre HUBERT 2020-03-31 16:32:25 +02:00
parent 92340bbc33
commit 821c8211cc
2 changed files with 16 additions and 9 deletions

View File

@ -172,15 +172,18 @@ export class UserWebSocketController {
await route.handler(handler); await route.handler(handler);
} catch(e) { } catch(e) {
console.error(e);
// Try again to send again a response
try { // Try to send a server error response
handler.sendResponse("error", { if(!handler.isResponseSent) {
code: 500, try {
message: "Server error" handler.sendResponse("error", {
}); code: 500,
} catch(e) { message: "Server error"
console.error(e); });
} catch(e) {
console.error(e);
}
} }
} }

View File

@ -15,6 +15,10 @@ export class UserWebSocketRequestsHandler extends BaseRequestsHandler {
constructor(private wsClient: ActiveClient, private req: WsMessage) { constructor(private wsClient: ActiveClient, private req: WsMessage) {
super(); super();
} }
public get isResponseSent() : boolean {
return this.sentResponse;
}
protected get userID(): number { protected get userID(): number {
return this.wsClient.userID; return this.wsClient.userID;