How to detect client-side errors

bonsai
Mega Sage

I would like to create a process that detects when an error occurs in a UI page, UI policy, or client script.

I know that you can use "try~catch" to catch errors, but is there a way to implement this in a single client script or the like to detect errors in the browser?
I considered incorporating "try~catch" into the client-side processing, but if there is a common error collection process, I would like to implement it.

I would like to be able to catch error events, etc.

Alternatively, if I could catch some kind of event and constantly determine errors, I think I could record browser errors.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@bonsai 

the only possible way is to use try catch block and if you wish to log it in system logs then within the catch block you can use GlideAjax to write to add it in system logs using gs.info()

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Hello Bonsai,

As discussed in previous threads and reiterated by Ankur in his response, this functionality isn't possible without using GlideAjax to log errors in a log table. Additionally, as I mentioned in one of your earlier queries, you can create a custom log table if extensive logging is required. I recommend developing a generic LogUtil Script Include that can be called from any client script in the future.

Hope this helps!