在body.process期间捕获CherryPy 3.2中的异常

时间:2015-02-22 16:58:37

标签: cherrypy turbogears

我在一个直播网站上收到以下错误,其中提交了一个utf字符(测试字符串'Îñţérñâţîöñåļîžæ†îøñ'):

400 Bad Request

The request entity could not be decoded. The following charsets were attempted: ['utf-8']

Traceback (most recent call last):
  File ".virtual/local/lib/python2.7/site-packages/cherrypy/_cprequest.py", line 648, in respond
    self.body.process()
  File ".virtual/local/lib/python2.7/site-packages/cherrypy/_cpreqbody.py", line 931, in process
    super(RequestBody, self).process()
  File ".virtual/local/lib/python2.7/site-packages/cherrypy/_cpreqbody.py", line 500, in process
    proc(self)
  File ".virtual/local/lib/python2.7/site-packages/cherrypy/_cpreqbody.py", line 153, in process_urlencoded
    "charsets were attempted: %s" % repr(entity.attempt_charsets))
HTTPError: (400, "The request entity could not be decoded. The following charsets were attempted: ['utf-8']")
Powered by CherryPy 3.2.0

我可以使用<form type="POST" accept-charset="utf-16">解决此问题。

通常情况下,我会在应用程序代码中捕获错误并将其记录下来或通过电子邮件发送给自己,但此错误从未到达在TurboGears 1.5上运行的应用程序代码。

我是否可以了解如何捕获和记录CherryPy生成的错误,其次,为用户提供更好的404页面?


_cperror.html#unanticipated-errors列出的错误处理方法  对于这种错误不起作用(但是例如缺少静态文件)

0 个答案:

没有答案