Hey,
HTTP code, as you're probably aware, are pretty much a solved dilemma
for the most common error cases. As for supplementing them with domain
specific errors, the following example is a reasonable one:
{
meta: {
version: 1,
status_code: 403
},
results: {
error: {
type: "KeyError",
message: "'xxx' is not a valid key for 'acmeapi'"
}
}
In ApiAxle these errors are actually being generated from a standard
node.js Error object which bubbles up through the stack when they
occur. I just decorate them with a (http) status code.
I would highly recommend avoiding magic numbers for codes they're a
total pita to maintain, you force users to have to look them up and
often they'll mean nothing to you when you're developing. Go text, no
doubt.
Cheers,
Phil
--
Apiaxle
http://apiaxle.com - A free, open proxy for your API.