Exception Handling in Javascript
Hi Team,
I'm trying to get the data into workflow transition from external API service.
Below is the code snippet to call the API for each record.
//function to call the api and return the response
function apiCall(url)
{
var http;
try{
http = new HttpClientRequest(url);
http.method = 'GET';
var response = http.execute();
}
catch(e){
http.disconnect();
return "Exception occured in ACM "+e +" for URL "+url;
logInfo("Exception occured in ACM "+e +" for URL "+url);
}
if(http.response !== undefined && http.response.code === 200)
{
var res_body = JSON.parse(http.response.body);
var status = res_body.response.status;
var details = res_body.response.details;
var r_id = res_body.response.id;
http.disconnect();
return res_body;
}
else{
var code = http.response.code;
http.disconnect();
return 'something went wrong '+code +" http code";
}
}But, This Code gets into exception sometimes and in exception object e only error code number is returned.
The exception code which I got is -60.
and as per the documentation, the exception object will only return the number.
doc link: https://docs.adobe.com/content/help/en/campaign-classic/technicalresources/api/p-4.html
I just want to know the reason for this exception. or is there any documentation available for these exceptions codes.
so, that I can handle this exception accordingly.
Thanks in advance!!
Regards,
Nitesh.