Our old developer, in some scripts, was throwing a...
# suitescript
m
Our old developer, in some scripts, was throwing an error in order to notify the script owner by email in some cases. This makes RESTlets respond with weird errors instead of responding with good structured error and code. So, how do you notify yourselves or admins? do you use the
mail
package?
b
you may actually want to keep the error throwing code as is
whatever client is using the restlet will need to handle how netsuite formats errors anyways
because netsuite can error before running your restlet code
m
No way I can explain that to this client 🙂
But I got what you mean.
s
I typically do not send errors directly with mail or modules. At most I'd configure the script page to send. Usually don't even do that - log to the error to the execution log. For the case of restlets specfiically return a well structured JSON error to the caller. Battk makes a good point that there are errors that can happen before your code even runs so make sure your 'structured error' format is similar to the native NS response.
For notification of errors we tend to use a saved search to pull errors and either have them on a dashboard or email if appropriate. That tends to be better accepted than spamming people with individual error emails.
by 'pull errors' it's either error level logs themselves or some other record/field that explicitly holds processing error info suitable for review by end users.
m
What do you mean by "have them on a dashboard or email if appropriate"? I understand the dashboard idea, but by email, you mean you send like a summary of the saved search by email?
b
i would recommend the custom record over the log, logs are fickle temporary things
m
I am already saving the body of the failed requests to a custom record, but I needed an alert, I don't want to keep watching it.
k
I would recommend to create a error custom records Search (in UI), trigger auto alert as soon as record created based on your requirement
s
have a search pull from that custom record at some periodic interval
✔️ 1
m
I guess this is a better idea. Thanks ❤️
s
we use a custom record we call the 'audit log' that we use when the use case is more serious than just using the server execution log 🙂