jfversluis / BeenPwned.Api

.NET Wrapper library for the haveibeenpwned.com API
https://haveibeenpwned.com
MIT License
8 stars 2 forks source link

No way to tell apart 'no result found' and other errors for Breaches and Pastes #6

Closed jfversluis closed 7 years ago

jfversluis commented 7 years ago

Currently the API returns an exception of type BeenPwnedUnavailableException with a message "Not Found" when no breaches (or pastes) are found.

On the consumer-side this poses a bit of a challenge. There is no way, besides string comparison on the exception message, to tell if an actual error happened (rate limit hit or whatever) or the result just came up empty.

There are a few alternatives to this:

IMHO it's not preferable to throw an exception for a simple thing like 'no result found'.