Try Catch With Exception Print
try {
//....code....
}
catch (e) {
// print Javascript Exception objects
for (i in e)
writeln(i, ' : ', e[i]);
// print BXS Exception objects
for (i in e.messages)
writeln(e.messages[i].id, ' : ', e.messages[i].text);
}