Flask错误500处理:渲染模板失败

时间:2014-02-07 13:28:29

标签: python error-handling flask

我想在Flask应用程序启动时处理数据库崩溃。我创建了@app.errorhandler(500),我希望返回render_template。此时数据库不可用。 render_template也失败了。我不知道为什么。有什么想法吗?

Exception in rendering template: could not connect to localhost:27017: [Errno 10061] No connection could be made because the target machine actively refused it
127.0.0.1 - - [07/Feb/2014 17:23:04] "GET /app/ HTTP/1.1" 500 -
Error on request:
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\werkzeug\serving.py", line 177, in run_wsgi
    execute(self.server.app)
  File "C:\Python27\lib\site-packages\werkzeug\serving.py", line 165, in execute
    application_iter = app(environ, start_response)
  File "C:\Python27\lib\site-packages\flask\app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "C:\Python27\lib\site-packages\flask\app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "C:\Python27\lib\site-packages\flask\app.py", line 1410, in handle_exception
    return handler(e)
  File "D:\proj\beardev\mcp\common\routes.py", line 101, in page_error
    raise ex
AutoReconnect: could not connect to localhost:27017: [Errno 10061] No connection could be made because the target machine actively refused it

0 个答案:

没有答案