-
-
Notifications
You must be signed in to change notification settings - Fork 561
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
Revise error handling to be more consistent for library users #180
Conversation
…e DeviceException for invalid tokens / checksum errors
* DeviceExceptions are catched in the base group (ExceptionHandlerGroup) * Token & ip validation is moved to click_common module
miio/vacuum_cli.py
Outdated
@@ -19,31 +18,14 @@ | |||
sys.exit(1) | |||
|
|||
import miio # noqa: E402 | |||
from miio.click_common import (ExceptionHandlerGroup, validate_ip, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module level import not at top of file
miio/plug_cli.py
Outdated
@@ -12,27 +11,14 @@ | |||
sys.exit(1) | |||
|
|||
import miio # noqa: E402 | |||
from miio.click_common import (ExceptionHandlerGroup, validate_ip, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module level import not at top of file
miio/philips_eyecare_cli.py
Outdated
@@ -10,6 +10,8 @@ | |||
sys.exit(1) | |||
|
|||
import miio # noqa: E402 | |||
from miio.click_common import (ExceptionHandlerGroup, validate_ip, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module level import not at top of file
miio/ceil_cli.py
Outdated
@@ -10,6 +10,8 @@ | |||
sys.exit(1) | |||
|
|||
import miio # noqa: E402 | |||
from miio.click_common import (ExceptionHandlerGroup, validate_ip, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module level import not at top of file
miio/click_common.py
Outdated
import click | ||
import ipaddress | ||
import miio | ||
import logging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module level import not at top of file
miio/click_common.py
Outdated
|
||
import click | ||
import ipaddress | ||
import miio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module level import not at top of file
miio/click_common.py
Outdated
sys.exit(1) | ||
|
||
import click | ||
import ipaddress |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module level import not at top of file
miio/click_common.py
Outdated
sys.version_info) | ||
sys.exit(1) | ||
|
||
import click |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module level import not at top of file
print("To use this script you need python 3.4 or newer, got %s" % | ||
sys.version_info) | ||
sys.exit(1) | ||
import click |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module level import not at top of file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The printout has to be before trying to import miio
as otherwise it'll bail out with syntax errors.
Users of the library can catch
miio.DeviceException
for catching both communication errors as well as errors reported by the devices (which are of typemiio.DeviceError
extending fromDeviceException
).