Try catch in script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2020 03:53 AM
Hi,
I am publishing a scripted web service and have code in the script include. For better error handling of an unexpected error, thinking of using try-catch block.
Can anybody share a code snippet of how to use a try-catch block for displaying the error message in response to the API call?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2022 07:47 AM
Could you help me check why this script is not working?
var vendorName = current.variables.vendor_name.
var vendorURL = current.variables.vendor_
try {
var r = new sn_ws.RESTMessageV2('Push Data to Panorays on Vendor Onboard', 'POST');
r.setStringParameterNoEscape('
r.setStringParameterNoEscape('
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
if (httpStatus == 200){
gs.info("Panorays successfully updated for: " + vendorName);
current.work_notes = 'Success Panorays API Call';
gs.addInfoMessage("Panorays was successfully updated");
}
if(httpStatus == 400){
gs.addErrorMessage("Panorays update failed");
current.work_notes = 'Failed Panorays API Call';
gs.error("Panorays update failed for: " + vendorName);
}
}
catch(ex) {
var message = ex.message;
gs.error("Error in system logs: " + message);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2023 02:31 AM
what is the error message you're receiving?