I\'m working on a RESTful web service in Java. I need a good way to send error messages to the client if something\'s wrong.
According to the Javadoc, HttpServlet
I'm not quite familiar with the 'best practices' around REST. But I know the concept is based on HTTP and how it is supposed to work out naturally. So how about using a mime type and simple text inside the body for an application error, like 'application/myapp-exception' and some 'Bla bla'? You can provide a client library for that.
I would not use HTTP response codes for application errors. Because I like to know what's failing: whether it is my application or my HTTP server.
(I hope, I'll see some best practice advices here, too.)