diff --git a/src/routes/cheque.route.js b/src/routes/cheque.route.js index 5725501..cab479d 100644 --- a/src/routes/cheque.route.js +++ b/src/routes/cheque.route.js @@ -107,8 +107,18 @@ const revokeStop = async (req, res) => { console.log('response from stop cheque api: ', response.data); return res.json(response.data); - } catch (error) { - logger.error('Unable to fetch cheque data: ', error); + } catch (e) { + logger.error('Unable to fetch cheque data: ', e); + if (axios.isAxiosError(e)) { + if (e.response) { + // Server responded with a status outside 2xx + return res.status(e.response.status).json(e.response.data); + } else { + return res + .status(e.response.status) + .json({ error: 'UNKNOWN', message: 'NO_RESPONSE_FROM_CBS' }); + } + } return res.status(500).json({ error: 'INTERNAL_SERVER_ERROR' }); } };