I am currently writing an API / some clients for chess games.

The developers should access the API via one script (xhrframework.php) and submit the actions via GET. It is possible that they make some errors when they submit the actions (No PHPSESSID sent, no valid PHPSESSID, move was not valid, it's not their turn, ...).

So I thought about the posibilities how to display errors. I came up with some ideas how to inform the programmer, that he made an error:

  1. via an error message in clear english
    • +: It is clear what the error should mean
    • +: Information how to fix this error can be added
    • -: The message might change as my english isn't very good
    • -: The length of the message differs quite a lot - this might be important for C programmers
  2. via ab error message constant in english - something like WRONG_PHPSESSID, MISSING_PHPSESSID, INVALID_MOVE, NOT_YOUR_TURN, ...
    • +: It's understandable for a human
    • 0: It's almost sure that the message doesn't change
    • -: The length of the message might differ a bit
  3. via an error code with one table in the documentation where the programmer can find the meaning of the error code
    • +: The error code would be constant
    • +: The lenght of every error code could be the same
    • -: It's cryptic

I thoguht the third solution might be a good idea as the xhrframework.php should only be accessed by a programmer who quite possible took already a look at the API documentation.

Now I would like to know if a standard for Web-API-Error messages does exist. How did others (e.g. Google Maps API) solve this? Should I simply output a blank page with the content "ERROR: 004" or without padding "ERROR: 4"?

Which errors should get which numbers? Does ist make sense to group errors by their numbers, e.g. all errors beginning with 1 were authentification errors, all err

Edit
Report