If I demand a resource X through
client.Execute<X> and it fails because of 401 Unauthorize, should the method raise an exception or return
null? I think it should throw. If you agree, then 401 and 500 have to be treated the same - an exception has to be raised and we even know which exception -
WebException. Moreover, we do not need to create this exception - the underlying infrastructure has already created it for us. Of course, some of its properties are crap, but it embeds the response object, which has all the info we need. Maybe we could rethrow it as a different exception, but this is details.
Now, if you disagree with me, then
client.Execute<X> should return null on 401, but throw an exception on 500 (or return null as well ?). I do not see how this makes the client life easier. Yes, we are being strict about the HTTP status code nuances at the expense of the client code simplicity.
--
Be well and prosper.
==============================
"There are two kinds of people.Those whose guns are loaded and those who dig."
("The good, the bad and the ugly")
So let us drink for our guns always be loaded.