Why is nesting or piggybacking errors within errors bad in general?
To me it seems bad intuitively, but I'm suspicious in that I cannot adequately articulate why it is bad. This may be because it is not in general bad and that it is only bad in specific instances. Why is it detrimental to design error/exception handling in such a way.
The specific instance is that of a REST service. There is a desire by some to use http errors (specifically the 500 response) as a way to indicate any problem with specific instances of a resource. An example of an instance resource in this case would be:
http://server/ticket/80 # instance http://server/ticket # not an instance
So this is the behavior that is being proposed.
- If
ticket 80
does not exist return a http response code of500
. Within the body of the error return the "real" error as an additional error code and description. - If the
ticket
resource doesn't exist return a response code of 404.
http://server/ticket
doesn't seem like a well-formed URL to me, since the information needed to fulfill the request is missing; it should also return a 404.http://server/ticket
, 404 seems like a reasonable error code. 410 ("Gone") might also make sense, because unlike 404 it indicates that the resource is not going to be back later.