SS2 Suitelet. Sometimes an error occurs in my cod...
# suitescript
c
SS2 Suitelet. Sometimes an error occurs in my code and I want to report this to the script owner (or whoever is specified in the Unhandled Errors subtab) without breaking execution. This means I don't want to raise an exception. How can I do this?
a
Catch the error in a try-catch block but instead of 'throwing' - send an email.
c
How do I send an email to the script owner (or whoever is specified in the Unhandled Errors subtab)?
b
use N/record to load the script record and start reading fields
j
You can use runtime.getCurrentScript() to get the currently executing script
A script is a record, so you should be able to retrieve the owner of that script to target the right recipient
c
Seems crazy that this isn't built in. Surely "sending notification of error and then continue execution" is a common use case
j
I think the emails are more for when something’s properly broken and didn’t fail gracefully
otherwise, logging is usually the way people handle things
Agree with you that it would be nice to have though. Lots of stuff like that in NS…. missing stuff that seems basic
c
Ok, thank you all for help