[英]How do I raise a custom exception with google cloud endpoints in Java?
So I can see in the docs for Python you can just go: 因此,我可以在Python文档中看到您可以执行的操作:
raise endpoints.NotFoundException(message)
( https://developers.google.com/appengine/docs/python/endpoints/exceptions ) ( https://developers.google.com/appengine/docs/python/endpoints/exceptions )
so in Java I tried: 所以在Java中我尝试了:
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Event has no attendee!");
when I do this in Java I get: 当我在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]"
}
}
How do I do this properly? 如何正确执行此操作? Thanks!
谢谢!
请参阅上面的评论,这非常适合我的需求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.