In a RESTlet, how do you feel about wrapping the e...
# suitescript
w
In a RESTlet, how do you feel about wrapping the entire get/put/post entrypoint in a try catch
Copy code
try {
  // the stuff to do
} catch(e) {
  log.error('error',{requestBody, e})
  throw e
}
Would it affect performance? What I want to achive is not to have to log every call to the RESTlet and still be able to see what the request was if/when it errors out.
d
There should not be any performance reduction using try/catch
r
I like it @Watz - without it, sometimes you can get an unexpected error thrown and if you're expecting a certain response in another system it can be troublesome.
s
I control logging by using a different logger... which lets me set logging threshold so I don't need to use constructs like exception handling to control that?
w
@stalbert could you explain a little more detailed how that would log unhandled exceptions? (bugs of course)
s
if your goal is to catch outermost errors then yes try/catch is a reasonable approach
m
Does rethrowing the error like that keep the original stack trace?
w
@michoel from what I've seen, yes.
👍 1