title: Bottle/python error handling with default_error_handler
body: <p>With bottle/python I'm trying to get a more detailed error handling. There is a page describing a method 
  <a href="https://stackoverflow.com/questions/30854686/how-to-return-error-messages-in-json-with-bottle-httperror/42566998#42566998">How to return error messages in JSON with Bottle HTTPError?</a>, but can't implement it with my project. </p>
  
  <p>ara.hayrabedian's answer on the mentioned page works, but with the hope to get more details for error situations Michael's code has some charm. Only any variation I tested fails. Basically I have (out of a longer coding):</p>
  
  <pre><code>#!/usr/bin/env python
  # -*- coding: utf-8 -*-
  from bottle import Bottle, run, static_file, view, template, \
                     get, post, request, debug
  from bottle import route, response, error
  import json
  
  app = Bottle()
  
  #class JSONErrorBottle(bottle.Bottle):   ### just an not working alternative!?
  class JSONErrorBottle(Bottle):
      def default_error_handler(app, res):
          bottle.response.content_type = 'application/json'
          print("XXXXXXX " + json.dumps(dict(error=res.body, status_code=res.status_code)))
          return json.dumps(dict(error=res.body, status_code=res.status_code))
  
  app.install(JSONErrorBottle)
  
  def main():
       app.run(host = prefs['server'], port = prefs['port'], reloader=False)
  
  if __name__ == '__main__':
      rcode = main()
  </code></pre>
  
  <p>Calling an invalid page that 'default_error_handler' isn't called, just the standard bottle html error page with "Error: 404 Not Found"</p>