jgiacomini / Tiny.RestClient

Simpliest Fluent REST client for .NET
MIT License
210 stars 30 forks source link

Http librairie should not through http exception #80

Closed guillaumechervetaxa closed 5 years ago

guillaumechervetaxa commented 5 years ago

Hi,

I think that this libraries should not through exception when http 400 code is returned. The status code is an information not a crash. It is the same for 500 status code. The response can contain useful information. The exception behavior intricate the code behind. It is the consumer choice to through an Exception or not and that depends of your needs.

What do you think about?

Regards,

malotho-zz commented 5 years ago

Definitely, the user should decide whether to they throw an exception or not.

jgiacomini commented 5 years ago

Hello,

I open to discuss about it. But for me when server throw a status 400 or 500 the response have not the same format. It's why I throw an exception.

On HttpException on this case you have a property named content with the body on the server response.

jgiacomini commented 5 years ago

@guillaumechervetaxa I thought about this feature I am working on it.

guillaumechervetaxa commented 5 years ago

You can look at this implementation that look good => https://developer.mozilla.org/fr/docs/Web/API/Fetch_API/Using_Fetch

Your library will be more usable in functional/declarative way (all the language evolve in this way) when you will remove exception

jgiacomini commented 5 years ago

@guillaumechervetaxa you can start to read what I start to implement in this PR =>#81. @malotho && @guillaumechervetaxa if you are ok with the implementation all client, I will add it the same logic for each request. :)

jgiacomini commented 5 years ago

It's done in 1.7.0