From c5e3e796bf06468441b09efed02d1832934d4e24 Mon Sep 17 00:00:00 2001 From: nguyentrungthat <80239428+nguentrungthat@users.noreply.github.com> Date: Sat, 17 Jan 2026 11:31:49 +0700 Subject: [PATCH] Add error handling for external service calls Wrapped calls to axios, sendMessageToMail, and sendMessageToZulip in try-catch blocks to handle errors individually and log them. This prevents one failure from blocking the execution of subsequent service calls. --- BACKEND/providers/socket_io_provider.ts | 44 ++++++++++++++++--------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/BACKEND/providers/socket_io_provider.ts b/BACKEND/providers/socket_io_provider.ts index dc8331b..ec6d0b8 100644 --- a/BACKEND/providers/socket_io_provider.ts +++ b/BACKEND/providers/socket_io_provider.ts @@ -623,23 +623,35 @@ export class WebSocketIo { const linkWiki = process.env.LINK_WIKI || 'https://logs.danielvu.com/api/wiki/page/insert?title=Dev_test' - await axios.post(linkWiki, { - data: tableHTML, - titleAuto: `[${scenarioName || 'DPELP'}] - ${stationName} - ` + dataFormat, - }) - await sendMessageToMail( - `[${scenarioName || 'DPELP'}] - ${stationName} - ${dataFormat}`, - tableHTML - ) - await sendMessageToZulip( - 'stream', - 'ATC_Report', - station.name, - `\n\n---\n**[${scenarioName || 'DPELP'}] - ${stationName} - ${dataFormat}**\n\n` + - zulipMess - ) + try { + await axios.post(linkWiki, { + data: tableHTML, + titleAuto: `[${scenarioName || 'DPELP'}] - ${stationName} - ` + dataFormat, + }) + } catch (error) { + console.error(error) + } + try { + await sendMessageToMail( + `[${scenarioName || 'DPELP'}] - ${stationName} - ${dataFormat}`, + tableHTML + ) + } catch (error) { + console.error(error) + } + try { + await sendMessageToZulip( + 'stream', + 'ATC_Report', + station.name, + `\n\n---\n**[${scenarioName || 'DPELP'}] - ${stationName} - ${dataFormat}**\n\n` + + zulipMess + ) + } catch (error) { + console.error(error) + } } catch (error) { - console.log(error) + console.error(error) } })