jfversluis / been-pwned

App that leverages the haveibeenpwned.com API by Troy Hunt. This app is available in the App Stores and is used in several of my talks as well as my book Xamarin.Forms Essentials.
MIT License
16 stars 3 forks source link

What to do when no data is found #23

Closed sthewissen closed 7 years ago

sthewissen commented 7 years ago

Currently the API returns an exception of type BeenPwnedUnavailableException with a message "Not Found" when no breaches are found. There are a few alternatives to this:

  1. Return an empty List<Breach>.
  2. Return an actual status code enum.
  3. Leave it like this.
  4. Some other option I'm forgetting.

We probably need to make a choice on what the best option is @Depechie @jfversluis. Imho 3 is not the way to go due to the message "Not Found" being a string and all.

Depechie commented 7 years ago

You guys are going way to fast for me ;) Normally on web api's I work on we only return http error codes and no special exceptions so that a wide range of programs can consume it. And the rest parser uses those http codes client side to handle them. Generally we then show a notification somewhere in the app if there was a real exception and return null or empty list. Listviews show message indicating no data found if needed....

jfversluis commented 7 years ago

Keep up @Depechie! It's done almost already 😉

Fixed the issue in the NuGet. No result now just returns an empty collection. Updated package and code accordingly in #24

jfversluis commented 7 years ago

Fixed and merged, ciao!