Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API needs to be able to report failure to detect, errors #21

Open
BartMassey opened this issue Aug 13, 2022 · 4 comments
Open

API needs to be able to report failure to detect, errors #21

BartMassey opened this issue Aug 13, 2022 · 4 comments

Comments

@BartMassey
Copy link

Right now if something goes wrong — can't detect mode, error happens during detection attempt — detect() returns Mode::Light. Would be a lot better to provide some version of this that could return a Result.

@edfloreshz
Copy link
Collaborator

I believe this is by design, when a failure occurs Mode::Light is taken as the fallback mode.

Adding a Result would over-complicate things in my opinion, as an alternative I would suggest adding an Error variant to the Mode enum.

@BartMassey
Copy link
Author

An Error "mode" means that every match against mode will need to handle this case. A Result can be checked for, leaving an actual mode to work with.

If the endpoint uses Result<Mode, Error> one can get the old behavior by

detect().unwrap_or(Mode::Light)

if desired.

@edfloreshz
Copy link
Collaborator

@frewsxcv What do you think? I think I brought this up at some point.

@frewsxcv
Copy link
Owner

Having it return a Result seems reasonable to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants