Customized Default Exception Handling

I have always wondered about customizing the default exception handling when in the perspective context… Can someone tell me why this is a bad idea?

Something akin to:

import sys

# If perspective scripting is available in this context
if hasattr(system, 'perspective'):
    sys.excepthook = lambda type, exception, traceback : myFunctionToShowUserError(type, exception, traceback)

@pturmel I feel like you’d know this for Vision, maybe the answer applies in Perspective as well.

2 Likes

To note, in my efforts, I haven’t got my exact example to work how I am expecting it.

However I know its possible if I dig around enough! Just need to find the right type of exception to override… lol

Well, even if this works, it won’t just be Perspective, it’ll be everything on the gateway. Possibly isolated to within a particular project’s “script manager”?

Well, everything Jython. I wouldn’t expect it to catch Java exceptions.