Refactor error handling in main function

This commit is contained in:
Aaro Varis
2024-09-21 22:23:14 +03:00
parent ebba3618b6
commit a01dd2a7b7

View File

@@ -59,7 +59,18 @@ async function main() {
data: response.data
});
} catch (error) {
console.error(error);
if (RETRY_ERROR_CODES.includes(error.response.status)) {
console.log(`Retrying request ${requestObj.id} for instance ${instanceId}`);
SetTimeout(() => {
DoRequest(instanceId, requestObj);
}, 5000);
} else {
RegisterResponse(instanceId, {
id: requestObj.id,
data: error.response.data,
error: "yep there was an error"
});
}
}
}