Also, is there a way to log the exception and stac...
# suitescript
b
Also, is there a way to log the exception and stack trace when an exception is thrown in a restlet function? does
e.message
and
e.stack
work here?
e
try..catch
and the
N/log
module should work exactly the same in a Restlet as they do elsewhere.
k
What Eric said + when you log these, set the details property of the log method to the variable used in your catch function. e.g.
Copy code
try {
} catch (e) {
  log.error({
    title: 'my error',
    details: e
  });
}
👍 1
b
thanks, but i want to return it in the output to the user (i am executing that restlet using a 3rd party app), not to see it in the execution log.
e
What is preventing you from doing so?
k
Copy code
try {
} catch (e) {
  log.error({
    title: 'my error',
    details: e
  });
  return e;
}
Restlets that have a Content-Type of application/json will return a native object. In your catch, the variable is set as an error object. Just return that variable in your restlet.