RestCode / WebApiProxy

MIT License
199 stars 91 forks source link

Why EnsureSuccess #48

Closed JeroenOris closed 8 years ago

JeroenOris commented 9 years ago

why is there an EnsureSuccess function added to the clients in this commit? https://github.com/faniereynders/WebApiProxy/commit/59fe0c6ae656121aa6f10392d5758dab869d7049 In some servers you get an error response when no data is found (404) or a malformed request is made (403). It's not possible any more to use these services with this project. What is other people's opinion about this? Remove the ensuresuccess function?

Yoerids commented 9 years ago

Exactly. We have the same problem. Some of our business rule validation errors return a 403 response...

faniereynders commented 9 years ago

The reason for this is to handle the applicable response accordingly by wrapping the call in a try/catch. If the server returns any status 5XX and 4XX it suggests a server or client error respectively and this should then be handled in the appropriate catch block. This mainly prevents a whole lot of 'if' operations.

faniereynders commented 8 years ago

Let's move any potential further discussions to #73