Search code examples
httpexceptionhttp-response-codes

Http Response Code for Expected Server Error


What is the recommended HTTP response code for an expected server error? I know that 500 is for a server error, but it is typically for an unexpected error.

What if you wanted to throw an exception and allow the client to deal with it? Doesn't a 500 response code seem incorrect for that? What number should be used?


Solution

  • HTTP response codes should only reflect the status of the request itself. Something like a spam filter is endemic to the workings of your application, and has no bearing on the status of the HTTP request and response. Similar question here: How to show the internal server errors to the user?