Very simply, you’ll never make it, understand why.
The reason is, errors with code 500
to 599
, are usually associated with errors in the server application, which failed to operate a request.
What you should do is first, any error within that interval between 500
and 599
, should be treated as a failure in the API and you should treat it even without knowing the reason for the failure. That is, check the httpstatus
before anything, if you are among 500
and 599
, treat as an API failure and don’t expect it to return the reason for the failure.
Keep in mind that if you send a value the API does not expect and it returns an error 500
for example, it is probably because the type of value you are sending is unexpected.
Contrary to the above situation, if the API treats a type of data that is not expected, it is very likely to return an error to you 400
and the reason for the error.
Reference: List of HTTP status codes
Put the code in for the guys to help you better
– JuniorNunes