Contents
When does the server return a 500 internal error?
The server is returning a 500 Internal Server Error for a query on one of those IDs. In my application, an exception is thrown and I don’t see details about the error.
Is it good practice to send errors back?
At the end of the day it’s an API sending back responses and not views, so I think it’s fine to send back a message with the exception and status code to the consumer. I currently haven’t needed to accumulate errors and send them back as most exceptions are usually due to incorrect parameters or calls etc.
What are the different types of error codes?
400s: Client error codes indicating that there was a problem with the request. 500s: Server error codes indicating that the request was accepted, but that an error on the server prevented the fulfillment of the request. Within each of these classes, a variety of server codes exist and may be returned by the server.
Is it necessary to return a 404 status code?
Returning an error payload in the body is reasonable, but not required. According to RFC 2616, the definition of the 404 status code is: The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent.
When to return error code 500 in REST API?
We are building a new REST API. I was arguing that error code 500 (Internal Server Error) should never be returned. Now, of course if you know the client’s params are wrong or something you have everything under control and can return some appropriate error code (e.g. 422). So if an unexpected error occurs the server could:
What does a 500 status error code mean?
There are a lot of different types of 500 status error codes (500, 501, 502, 503, 504, etc.) and they all mean something different. In this case, a 500 internal server error indicates that the server encountered an unexpected condition that prevented it from fulfilling the request (RFC 7231, section 6.6.1).
When do I use a 500 series error?
If the error is caused by anything other than the inputs explicitly or implicitly supplied by the request, then I would say a 500 error is likely appropriate. So a failed database connection or other unpredictable error is accurately represented by a 500 series error.