title: Set Python to Quit On Exception?
body: <p>I'm using <code>Python 3</code></p>
  
  <p>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.</p>
  
  <p>I'd rather not add <code>try: except blocks</code> 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? </p>
  
  <p>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? </p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <hr>
  
  <p>After Googling, it would appear that a similar question with a solid answer has been asked <a href="https://stackoverflow.com/questions/15605925/how-to-get-the-last-exception-object-after-an-error-is-raised-at-a-python-prompt">here</a>, 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.</p>
  
  <p>Thanks for the help.</p>