title: Flask and sys.excepthook
body: <p>I want to add global exception handling object to my Flask webproject. In main module, where application class is created I've added code to override <code>sys.excepthook</code>. Here is simple test code:</p>
  
  <pre><code>import sys
  
  def my_exception_hook(exception_type, value, traceback):
      print "My exception handler"
      print "  Exception type:", exception_type
      print "  Exception instance:", value
      print "  Traceback:", traceback
  
      sys.__excepthook__(exception_type, value, traceback)
  
  sys.excepthook = my_exception_hook
  
  from flask import Flask
  import requests
  
  app = Flask(__name__)
  
  @app.route('/')
  def index():
      #Exception raised here "requests.exceptions.MissingSchema" not captured by my handler
      r = requests.get('ololo', auth=('user', 'pass'))
      return "Hello, world!"
  
  #raise Exception("AAA") #Exception raised here is successfully goes to my_exception_hook
  
  app.run(debug=True, port=5001)
  </code></pre>
  
  <p>I do not want and have no possibility to envelop each call or <code>requests</code> module with <code>try/catch</code>. Also I want to handle other eaception, for example, mongoDB connection problem which may occured spontaneousely (not wheen I creating connection), please do not suggest it.</p>