Refactor error handling in main function
This commit is contained in:
13
index.js
13
index.js
@@ -59,7 +59,18 @@ async function main() {
|
|||||||
data: response.data
|
data: response.data
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} 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"
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user