Is there any way in perspective to set up a project such that any errors in event scripts (e.g. on component actions) get logged to the browser console?
(the answer here might be ‘ignition module’. i’m comfortable with it being ignition module)
X-Y problem: if i as a user click a button in a perspective session and the button doesn’t work, i want to have some way of seeing ‘hey the button didn’t work and here’s why’ so i can report that
Automatically, no.
Perspective event scripts run in the gateway, and have no direct access to the browser itself. The only tool is system.perspective.print(), which you'd have to put in a decorator, and decorate all your library scripts, and ensure all of your Perspective events/transforms delegate to the project library.
1 Like
if i wrote all my event scripts as
function header from ignition():
try:
body
catch (Exception,java.lang.Exception) as e
system.perspective.print(e.stacktrace())
throw e
would this break for any obvious reasons
Don’t think that would necessarily break anything - but I wouldn’t write all my code like that.
Make a decorator that does that bit - try/except and system.perspective.print, and make sure all your event scripts are one line function calls. Then decorate the functions you are trying to debug with the decorator.
Plenty of examples on the forum of how to write a decorator if you look
2 Likes