From 29e442677b70ed9a4751430396552066c28b2bdf Mon Sep 17 00:00:00 2001 From: Dave Smith-Hayes Date: Wed, 23 Oct 2024 22:04:04 -0400 Subject: [PATCH] Adding a try/catch to the websocket constructor. --- chat-app/frontend/websocket.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/chat-app/frontend/websocket.js b/chat-app/frontend/websocket.js index b61372c..0c104ed 100644 --- a/chat-app/frontend/websocket.js +++ b/chat-app/frontend/websocket.js @@ -1,3 +1,8 @@ export function createWebSocket() { - return new WebSocket("ws://localhost:3000/chat-service"); + try { + return new WebSocket("ws://localhost:3000/chat-service"); + } catch (e) { + console.error(e); + throw e; + } }