Exception Handling in Javascript

Avatar

Avatar

nitesha38268385

Avatar

nitesha38268385

nitesha38268385

20-08-2020

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.

API Api call in workflow exception javascript workflow

Accepted Solutions (0)

Answers (2)

Answers (2)

Avatar

Avatar

Sukrity_Wadhwa

Employee

Avatar

Sukrity_Wadhwa

Employee

Sukrity_Wadhwa
Employee

31-08-2020

Hi @nitesha38268385,

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

Thanks!

Avatar

Avatar

Milan_Vucetic

MVP

Avatar

Milan_Vucetic

MVP

Milan_Vucetic
MVP

21-08-2020

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