Autodesk passes all exceptions thrown in the command engine when in GUI mode to maya.utils._guiExceptHook, rather than doing it the way that Python does it natively through sys.excepthook. Here’s a simple workaround if you want to modify that behavior at run-time.