I just stumbled across this post because I have the same question.
The links that Shan sent refer to server codes as seen in the log, not codes as returned by the ArcGIS REST API when making HTTP requests.
As seen in Flavie's example above, 500 is often returned when something's really wrong, like you used the wrong map service URL for a query or there's an internal server error. From memory, I seem to recall that you get a 498 error when a server is using the legacy "tokens" authentication method and the token is invalid. I've seen 499 errors too, but I don't recall what problem a 499 describes.
Anecdotally, I have noticed that the error series follows HTTP error code series (4XX errors are a problem with the client's request, and 5XX errors are a problem on the server). But that doesn't really help when you're trying to understand the range of possible codes.
A list of possible ArcGIS REST API codes (along with their meaning) would be quite helpful.
-Jeff