webapp2/App Engine 中的调试模式不输出错误或堆栈跟踪
我正在使用最新版本的 Google App Engine、Python 2.7 和 webapp2,但启用调试模式只会在出现错误时显示空白 HTML 页面,而不是显示错误和堆栈跟踪。这看起来不像预期的行为:
“在调试模式下,现在捕获的任何异常都会引发,并向客户端显示堆栈跟踪” http://webapp-improved.appspot.com/guide/app.html
我做错了什么吗?如果没有,如何使用 webapp2 中的自定义错误处理程序打印堆栈跟踪?
谢谢。
编辑:这是一个重现错误的示例应用程序:
app.yaml
application: testapp
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: main.app
libraries:
- name: jinja2
version: "2.6"
main.py
import webapp2
# Run application
app = webapp2.WSGIApplication([webapp2.Route('/', handler='handlers.IndexHandler')], debug=True)
由于没有名为“handlers.py”的文件包含 IndexHandler,因此该应用程序会引发 500 服务器错误。但即使 debug = True,应用程序也仅显示一个空页面,并且不会输出错误和堆栈跟踪(App Engine 日志除外)。
我还没有在生产服务器上尝试过这个。
I'm using the latest version of Google App Engine, Python 2.7 and webapp2, but enabling debug mode just gives me a blank HTML page on error rather than displaying the error and stack trace. This does not seem like the expected behavior:
"When in debug mode, any exception that is now caught is raised and the stack trace is displayed to the client"
http://webapp-improved.appspot.com/guide/app.html
Am I doing something wrong? If not, how can I print the stack trace using a custom error handler in webapp2?
Thanks.
EDIT: Here's an example app that reproduces the error:
app.yaml
application: testapp
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: main.app
libraries:
- name: jinja2
version: "2.6"
main.py
import webapp2
# Run application
app = webapp2.WSGIApplication([webapp2.Route('/', handler='handlers.IndexHandler')], debug=True)
Because there is no file called "handlers.py" containing IndexHandler, this app throws a 500 server error. But even though debug = True, the app just shows an empty page, and does not output the error and stack trace, except in the App Engine log.
I have not tried this on the production server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来这个错误在最新版本的 webapp2 中已修复:
http://code.google.com/p/webapp-improved/source/detail?r=da20281cbba3f593ca49667752c0a2395ea483c5
我想该修复最终将包含在 App Engine SDK 中。
Seems like this bug was fixed in the latest version of webapp2:
http://code.google.com/p/webapp-improved/source/detail?r=da20281cbba3f593ca49667752c0a2395ea483c5
I guess the fix will be included in the App Engine SDK eventually.