1

我有以下处理程序从收到的请求中获取内容:

class DummyHandler(webapp2.RequestHandler):
    def get(self):
        try:
             msg = cgi.escape(self.request.get('content'))
             if msg is None:
                raise IllegalContent
        except IllegalContent as ex:
            logging.error("Illegal content received")
            self.error(RequestErrorCodes.ILLEGAL_CONTENT)
        except Exception as ex:
            logging.error(ex) 
            self.error(RequestErrorCodes.UNEXPECTED_ERROR)

当我运行单元测试时,我收到以下错误:

    self.error(RequestErrorCodes.UNEXPECTED_ERROR)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 582, in error
    self.response.status = code
AttributeError: can't set attribute

我需要在 http 响应中定义用户特定的错误代码,以供我的客户处理。Google App Engine 是否支持此功能?

4

0 回答 0