Expand my Community achievements bar.

SOLVED

Exception Handling in Javascript

Avatar

Level 2

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.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 2

I didn't found any documentation for these Exception codes. but, the only exception we were facing was -60 so, we applied some hardcoded conditions to handle this exception.

and as per observation, this exception was occurred due to the network error on the instance.

View solution in original post

3 Replies

Avatar

Community Advisor

Hi @nitesha38268385

assume that you have whitelisted URLwhich you are hitting bellow.

Make some debuging by yourself. Call part of this function from the workflow within JS node with logInfo(http.execute()) where you will get more info about exception.

Hopefully, the new error you may find in this list: Error codes AC 

Regards,

Milan

Avatar

Administrator

Hi @nitesha38268385,

were you able to resolve this query with the given solution? Do let us know.

Thanks!



Sukrity Wadhwa

Avatar

Correct answer by
Level 2

I didn't found any documentation for these Exception codes. but, the only exception we were facing was -60 so, we applied some hardcoded conditions to handle this exception.

and as per observation, this exception was occurred due to the network error on the instance.