如何使用Java中的Google云端点提升自定义例外?

时间:2013-07-22 16:49:46

标签: java google-app-engine google-cloud-endpoints

所以我可以在Python的文档中看到你可以去:

raise endpoints.NotFoundException(message) 

https://developers.google.com/appengine/docs/python/endpoints/exceptions

所以在Java中我尝试过:

resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Event has no attendee!");

当我在Java中执行此操作时,我得到:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "badRequest",
    "message": "com.google.appengine.repackaged.org.codehaus.jackson.map.JsonMappingException: Can not construct instance of javax.servlet.http.HttpServletResponse, problem: abstract types can only be instantiated with additional type information\n at [Source: N/A; line: -1, column: -1]"
   }
  ],
  "code": 400,
  "message": "com.google.appengine.repackaged.org.codehaus.jackson.map.JsonMappingException: Can not construct instance of javax.servlet.http.HttpServletResponse, problem: abstract types can only be instantiated with additional type information\n at [Source: N/A; line: -1, column: -1]"
 }
}

我该如何正确地做到这一点?谢谢!

1 个答案:

答案 0 :(得分:0)

请参阅上面的评论,这对我需要的内容非常有用。