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:
Return an empty IEnumerable.
Return an actual status code enum. Include this in the BeenPwnedUnavailableException.
Distinguish different exception types.
Leave it like this.
Some other option I'm forgetting.
IMHO it's not preferable to throw an exception for a simple thing like 'no result found'.
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:
BeenPwnedUnavailableException
.IMHO it's not preferable to throw an exception for a simple thing like 'no result found'.