The API response can indicate an error condition, such as:
An error response includes a mnemonic code and a human-readable message. Programmers should rely on the code to detect and handle errors, because the message may change over time or appear in various national languages.
When possible, the error response is provided in the content type specified in the request. If the requested content type cannot be determined, the error response will use the XML content type.
The error response for each content type is, we hope, useful in context:
The error response is returned with an appropriate HTTP status code:
In addition to the error code and message described above, the Digg API returns an appropriate HTTP status code. Note that when the Javascript response type is specified, the status is always 200, because an error status prevents Javascript from running in many environments.
HTTP status 403 Forbidden is returned when the request is not valid.
Example:
GET /stories?appkey=example&count=500 HTTP/1.1 Host: services.digg.com Accept: */* ... HTTP/1.1 403 Forbidden Content-Type: text/xml;charset=UTF-8 Content-Length: 71 <error code="727321514" message="count may not be greater than 100" />
HTTP status 404 Not Found is used when the requested data does not exist, or when an endpoint is requested which does not exist.
Example:
GET /story/10000000?appkey=example&type=javascript&callback=example HTTP/1.1 Host: services.digg.com Accept: */* ... HTTP/1.1 404 Not Found Content-Type: text/javascript;charset=UTF-8 Content-Length: 15 throw 'Not found'
HTTP status 500 Internal Server Error is used when an internal error occurs.
Example:
GET /stories/popular?appkey=example&type=json HTTP/1.1
Host: services.digg.com
Accept: */*
...
HTTP/1.1 500 Internal Server Error
Content-Type: application/json;charset=UTF-8
Content-Length: 15
{"error":"Internal error"}
The API reports errors with both a code and a message. The code is more useful in programs, because the message may in future vary by national language.
Here is a list of all of the error codes used by the API. (Note that this list is created through a Javascript call to the List Errors endpoint.)
Page Information
|
Wiki Information
|
Recent PBwiki Blog Posts |