I am using Apache [HttpClient][1] and would like to communicate HTTP errors (400 Bad Request, 404 Not Found, 500 Server Error, etc.) via the Java exception mechanism to the calling code. Is there an exception in the Java standard library or in a widely used library that would be appropriate to use or to subclass for this purpose?
The alternative is to check status return codes. This appears to be the HttpClient design philosophy, but since these errors are truly exceptional in my app, I would like to have the stack trace and other nice exception things set up for me when they happen.
[1]: http://hc.apache.org/httpclient-3.x/
以上就是What Java exception class to use for HTTP errors?的详细内容,更多请关注web前端其它相关文章!