michielpost / Q42.HueApi

C# helper library to talk to the Philips Hue bridge
MIT License
412 stars 114 forks source link

LocalHueClient.RegisterAsync throws System.Exception when pushlink is required #182

Closed AngusMcIntyre closed 5 years ago

AngusMcIntyre commented 5 years ago

Catching System.Exception gives me the heebi jeebis. As far as I know, this is required so that user can be informed that a pushlink is required for app/device registration.

I believe the solution is either

  1. add a Q42.HueApi exception type for this error case or
  2. add or extend a Q42.HueApi exception type that specifies an error code

Should I submit either of the changes or is there a better way to catch these errors?

michielpost commented 5 years ago

Yes, you're absolutely right. throw new Exception... should not happen in this library. I think 1 is a nice solution. Create a generic HueException which can be used instead of the new Exception that is used right now, and then we can also create a more specific LinkButtonNotPressedException for this case.

If you can create a PR, I'd be happy to merge it. Thanks!