【发布时间】:2013-09-01 12:35:49
【问题描述】:
我正在寻找一种使用 Bottle 捕获 mako 运行时错误的方法。
使用以下代码捕获 Python 中的运行时错误:
# main.py
from lib import errors
import bottle
app = bottle.app()
app.error_handler = errors.handler
...
# lib/errors.py
from bottle import mako_template as template
def custom500(error):
return template('error/500')
handler = {
500: custom500
}
这可以完美运行,因为异常会变成 500 Internal Server Error。
我想以类似的方式捕获 mako 运行时错误,有人知道如何实现这一点吗?
【问题讨论】: