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.
This commit is contained in:
parent
c86824e589
commit
c5e3e796bf
|
|
@ -623,23 +623,35 @@ export class WebSocketIo {
|
||||||
|
|
||||||
const linkWiki =
|
const linkWiki =
|
||||||
process.env.LINK_WIKI || 'https://logs.danielvu.com/api/wiki/page/insert?title=Dev_test'
|
process.env.LINK_WIKI || 'https://logs.danielvu.com/api/wiki/page/insert?title=Dev_test'
|
||||||
await axios.post(linkWiki, {
|
try {
|
||||||
data: tableHTML,
|
await axios.post(linkWiki, {
|
||||||
titleAuto: `[${scenarioName || 'DPELP'}] - ${stationName} - ` + dataFormat,
|
data: tableHTML,
|
||||||
})
|
titleAuto: `[${scenarioName || 'DPELP'}] - ${stationName} - ` + dataFormat,
|
||||||
await sendMessageToMail(
|
})
|
||||||
`[${scenarioName || 'DPELP'}] - ${stationName} - ${dataFormat}`,
|
} catch (error) {
|
||||||
tableHTML
|
console.error(error)
|
||||||
)
|
}
|
||||||
await sendMessageToZulip(
|
try {
|
||||||
'stream',
|
await sendMessageToMail(
|
||||||
'ATC_Report',
|
`[${scenarioName || 'DPELP'}] - ${stationName} - ${dataFormat}`,
|
||||||
station.name,
|
tableHTML
|
||||||
`\n\n---\n**[${scenarioName || 'DPELP'}] - ${stationName} - ${dataFormat}**\n\n` +
|
)
|
||||||
zulipMess
|
} 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) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue