Run script skip msxml3.dll error

hi,

in the script below I perform a query on a remote server.
When there is no data I get the error:[0004] W3602 : Error 0 on line 9, column 1: msxml3.dll: De bewerking is afgebroken

line 9 is xhr.send. how can I skip this error and just stop the script from running?

var strUrl =  Watch.GetVariable("global.jasHTTPSLink") + Watch.GetVariable("global.jasFilename") 
+ "/?inp_status_delivery_enum=" + Watch.GetVariable("global.jasStatusCode") + 
"&inp_sourceorigin=" + Watch.GetVariable("bronOorsprong") + "&inp_datumtijd_van=" + 
Watch.GetVariable("global.jasQueryDate") + "T" + Watch.GetVariable("global.jasDailyQueryTime");
Watch.log(strUrl, 3);
var strUser =  Watch.GetVariable("global.jasUser");
var strPassword =  Watch.GetVariable("global.jasPassword");

var xhr = new ActiveXObject("Microsoft.XMLHTTP");
xhr.open("GET", strUrl, false, strUser, strPassword);

xhr.send();

var binaryStream = new ActiveXObject("ADODB.Stream")
binaryStream.Type = 1;
binaryStream.Mode = 3;
binaryStream.Open();
binaryStream.Write(xhr.responseBody);
binaryStream.SaveToFile(Watch.GetJobFileName(),2);
binaryStream.Close();

Wrap it in a Try…Catch structure:

var xhr = new ActiveXObject("Microsoft.XMLHTTP");
xhr.open("GET", strUrl, false, strUser, strPassword);

try {
  xhr.send();

  var binaryStream = new ActiveXObject("ADODB.Stream")
  binaryStream.Type = 1;
  binaryStream.Mode = 3;
  binaryStream.Open();
  binaryStream.Write(xhr.responseBody);
  binaryStream.SaveToFile(Watch.GetJobFileName(),2);
  binaryStream.Close();
} catch (e) {
  Watch.log("Error contacting the server : "+e,2);
}
1 Like