title: How to intercept all exceptions in flask?
body: <p>Perhaps I am not seeing something in the <a href="http://flask.pocoo.org/docs/quickstart/" rel="noreferrer">documentation</a>.</p>
  
  <p>I would like to not just handle some http errors, but all exceptions. The reason - I would like to log them using my own custom logic (sounds like reinventing the wheel, but I need full control over logging. I would like to not bring the server to its knees upon an exception, but bomb only that particular request.</p>
  
  <p>This is how I launch Flask now. Here <code>app.run</code> starts the server. How can I instruct it to call my exception handler method whenever an exception occurs?</p>
  
  <pre><code>def main():
      args = parse_args()
      app.config['PROPAGATE_EXCEPTIONS'] = True
      flask_options = {'port' : args.port}
      if args.host == 'public':
          flask_options['host'] = '0.0.0.0'
      app.run(**flask_options)
  
  if __name__ == '__main__':
      _sys.exit(main())
  </code></pre>