kevbite / CompaniesHouse.NET

A simple .NET client wrapper for CompaniesHouse API
MIT License
37 stars 44 forks source link

Handle 404 responses when retrieving company profile #4

Closed rmourato closed 8 years ago

rmourato commented 8 years ago

Hi again,

Yesterday I missed a basic scenario - attempting to retrieve a profile for an invalid company number...

Rather than forcing users to handle this exception it feels more idiomatic to return a null CompanyProfile on 404s, while still throwing on other non-success codes.

Proposed implementation is provided. I updated my tests to cover this scenario and keep a behavioral structure, but they may not follow the exact same style of your other ones. If you'd like them structured differently just let me know.

Cheers, Rui

kevbite commented 8 years ago

Normally we'd wrap it in to some more meaningful response so we can encapsulate other errors etc... but seeing as its so simple returning null seems fine.

Nice to see AppVeyor playing nicely now too!

I'll merge this in.

rmourato commented 8 years ago

Yes, could perhaps extend CompaniesHouseClientResponse<T> to have this info in? Will look into it if/when I do further changes.

Thanks for merging this in.