summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@flameeyes.eu>2018-12-12 23:26:58 +0100
committerDiego Elio Pettenò <flameeyes@flameeyes.eu>2018-12-12 23:33:57 +0100
commit457a733618cffc230a818520ccb223934867fbfe (patch)
tree1d77acdedbaad0661be6e0564f7b8458aff61391
parentReindent all files to match the 4-spaces indentation. (diff)
downloadglucometerutils-457a733618cffc230a818520ccb223934867fbfe.tar
glucometerutils-457a733618cffc230a818520ccb223934867fbfe.tar.gz
glucometerutils-457a733618cffc230a818520ccb223934867fbfe.tar.bz2
glucometerutils-457a733618cffc230a818520ccb223934867fbfe.tar.lz
glucometerutils-457a733618cffc230a818520ccb223934867fbfe.tar.xz
glucometerutils-457a733618cffc230a818520ccb223934867fbfe.tar.zst
glucometerutils-457a733618cffc230a818520ccb223934867fbfe.zip
-rw-r--r--glucometerutils/exceptions.py24
1 files changed, 10 insertions, 14 deletions
diff --git a/glucometerutils/exceptions.py b/glucometerutils/exceptions.py
index 9a0f1fd..b21c2ab 100644
--- a/glucometerutils/exceptions.py
+++ b/glucometerutils/exceptions.py
@@ -9,47 +9,43 @@ __license__ = 'MIT'
class Error(Exception):
"""Base class for the errors."""
- def __str__(self):
- return self.message
-
class CommandLineError(Error):
"""Error with commandline parameters provided."""
- def __init__(self, message=''):
- self.message = message
-
class ConnectionFailed(Error):
"""It was not possible to connect to the meter."""
def __init__(self, message='Unable to connect to the meter.'):
- self.message = message
+ super(ConnectionFailed, self).__init__(message=message)
class CommandError(Error):
"""It was not possible to send a command to the device."""
def __init__(self, message="Unable to send command to device."):
- self.message = message
+ super(CommandError, self).__init__(message=message)
class InvalidResponse(Error):
"""The response received from the meter was not understood"""
def __init__(self, response):
- self.message = 'Invalid response received:\n%s' % response
+ super(InvalidResponse, self).__init__(
+ 'Invalid response received:\n%s' % response)
class InvalidChecksum(InvalidResponse):
- def __init__(self, expected, gotten):
- self.message = (
- 'Response checksum not matching: %08x expected, %08x gotten' %
- (expected, gotten))
+ def __init__(self, expected, received):
+ super(InvalidChecksum, self).__init__(
+ 'Response checksum not matching: %08x expected, %08x received' %
+ (expected, received))
class InvalidGlucoseUnit(Error):
"""Unable to parse the given glucose unit"""
def __init__(self, unit):
- self.message = 'Invalid glucose unit received:\n%s' % unit
+ super(InvalidGlucoseUnit, self).__init__(
+ 'Invalid glucose unit received:\n%s' % unit)