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 =
|
||||
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)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue