停止活塞的错误捕获
我正在将 Piston 与 Django 一起使用。每当我的处理程序代码中出现错误时,我都会在 http 响应中获得该错误的简化的纯文本描述,这比 Django 在报告错误时提供的信息要少得多。我怎样才能阻止活塞以这种方式捕获错误?
I'm using Piston with Django. Anytime there's an error in my handler code, I get a simplified, text-only description of the error in my http response, which gives me much less information that Django does when it's reporting errors. How can I stop Piston catching errors in this way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在您的 settings.py 文件中,添加
PISTON_DISPLAY_ERRORS = False
这将导致引发异常,从而在您使用DEBUG = True
时在 Django 调试错误页面中按预期显示异常代码>.在某些情况下,异常不会正确传播。当 Piston 说函数定义不匹配时,我见过这种情况发生,但没有查看原因......
In your settings.py file, add
PISTON_DISPLAY_ERRORS = False
this will cause exceptions to be raised allowing them to be shown as expected in the Django debug error page when you are usingDEBUG = True
.There are a few cases when the exception won't propagate properly. I've seen it happen when Piston says that the function definition doesn't match, but haven't looked to see why...
也许您可以尝试覆盖
Resource.error_handle
,而不是使用默认实现:https://bitbucket.org/jespern/django-piston/src/c4b2d21db51a/piston/resource.py#cl-248
只是重新引发原始异常。
Maybe you could try to override
Resource.error_handle
, and instead of using the default implementation:https://bitbucket.org/jespern/django-piston/src/c4b2d21db51a/piston/resource.py#cl-248
just re-raise the original exception.