I'm using Python 3
I've been looking around for an answer to this, but I haven't found it yet. Basically, I'm running several Python scripts into a game engine, and each script has its own entry point.
I'd rather not add try: except blocks
through all of my code, so I was wondering if it's at all possible to tell Python to quit (or perhaps assign a custom function to that "callback") on finding its first error, regardless of where or what it found?
Currently, the game engine will continue after finding and hitting an error, making it more difficult than necessary to diagnose issues since running into one error may make a subsequent script not work (as it relies on variables that the error-ing script set, for example). Any ideas?
I know that I could redirect the console to a file to allow for easier scrolling, but just capturing the first error and stopping the game prematurely would be really useful.
Okay, a couple of extra bits of info - sorry for neglecting to say this. The engine I'm using (the Blender Game Engine) is coded in C, so changing the source is more than I'd like to do.
After Googling, it would appear that a similar question with a solid answer has been asked here, which is how to get the last raised exception. If I check the sys module for the presence of the last_value variable and it exists, then I can quit prematurely, as the console would have already printed out the error.
Thanks for the help.