Catch/trap error in Python code.InteractiveConsole
I have embedded a code.InteractiveConsole in a gui which works fine. I would like to trap (or read) errors to be able to send a error popup/message box but I can't seem to trace or trap errors in the console. I can redirect the stderr.write output to a function, but that triggers many errors as the stream is written to in chunks. Is there some good way to achieve this? For example this code below does not trap errors (although printed to stdout).
from code import InteractiveConsole
con = InteractiveConsole()
print('No error caught')
python error-handling console interpreter