Hey, I have a REST based server, and in some cases I want to return a failure code (400 for example), B开发者_JS百科UT, I wish to add additional URL. Something like - "failure, but here's what you can do now.." Is there any good convention to do so? Is it even a good idea to return error with additional information?
Thanks, Udi
It is always a good idea to return additional information in an error message. The HTTP spec itself says so: "Except when responding to a HEAD request, the server SHOULD include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition. These status codes are applicable to any request method. User agents SHOULD display any included entity to the user."
One thing to watch out for: some versions of Internet Explorer will not show the user your additional error information if it is not a certain number of bytes. Make sure your response entities for error messages are at least 512 bytes to be sure.
精彩评论