Can I use custom reasons for an HTTP status code to differentiated between errors for a REST API

I want to differentiate between separate types of "Not Found" errors. For Example given the following request:

GET /author/Adams/works/HHGTTG

Either the author could be 'not found' or the work could be'not found' and I want to differentiate between the two.

status: 404 - author not found
status: 404 - work not found

According to the spec the reason phrase can be changed. http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html

6.1.1 Status Code and Reason Phrase

...The reason phrases listed here are only recommendations -- they MAY be replaced by local equivalents without affecting the protocol...

Is it also acceptable to use two unique phrases for the same status code?

And, is this a sound approach or is there a better convention for indicating more granular errors?

Ultimately I want to have a client library that could throw either an AuthorNotFound or WorkNotFound exception instead of a generic AuthorOrWorkNotFound exception.

16
задан Brian R. Bondy 4 January 2011 в 18:00
поделиться