
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 12-04-2022 09:20 PM
There's a neat little script include provided OOB called NiceError.
The usage is very simple, simply invoke the script include constructor to get your message:
var msg = new NiceError("Some log message");
gs.info(msg);
What it does for you is where it gets interesting.
Stack traces are generated by native errors and tell you what callers an error passed through when the error was thrown. You would've seen them before in error messages generated by the instance when something goes very wrong in a script.
However we don't need to cause a fatal error to get a nice and useful stack trace. NiceError uses the fact that JS produces these stack traces to give us one without throwing and interrupting your program.
Here is an example Log message that was generated from NiceError:
How did we generate this?
I used a UI Action sitting on Incident, to call a script include, and that script include generated the log message internally after passing through a public and private method.
Script Include:
UI Action:
What about when generated via a business rule?
Even better, we actually get to know what triggered the BR:
In this case, it was just clicking Save.
The really good thing about this is that it scales as far as your scripts go, so a very long chain of scripts will still provide you the stack trace all the way back to the originating script:
In this example, the ErrorGeneratingScriptInclude has been updated to call another script include, which triggers the log message.
- 1,491 Views

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
If you're wondering how I got my syntax editor to look this way, I have another article for that:
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
This is awesome. Thanks so much!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Very tidy, I'll be using this.