停止活塞的错误捕获

发布于 2024-11-25 10:17:56 字数 123 浏览 4 评论 0原文

我正在将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

苦妄 2024-12-02 10:17:56

在您的 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 using DEBUG = 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...

养猫人 2024-12-02 10:17:56

也许您可以尝试覆盖 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文