summaryrefslogtreecommitdiffstats
path: root/glucometerutils/exceptions.py
diff options
context:
space:
mode:
Diffstat (limited to 'glucometerutils/exceptions.py')
-rw-r--r--glucometerutils/exceptions.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/glucometerutils/exceptions.py b/glucometerutils/exceptions.py
new file mode 100644
index 0000000..41dd701
--- /dev/null
+++ b/glucometerutils/exceptions.py
@@ -0,0 +1,29 @@
+"""Common exceptions for glucometerutils."""
+
+__author__ = 'Diego Elio Pettenò'
+__email__ = 'flameeyes@flameeyes.eu'
+__copyright__ = 'Copyright © 2013, Diego Elio Pettenò'
+__license__ = 'GPL v3 or later'
+
+class Error(Exception):
+ """Base class for the errors."""
+
+
+class InvalidResponse(Error):
+ """The response received from the meter was not understood"""
+
+ def __init__(self, response):
+ self.response = response
+
+ def __str__(self):
+ return 'Invalid response received:\n%s' % self.response
+
+
+class InvalidGlucoseUnit(Error):
+ """Unable to parse the given glucose unit"""
+
+ def __init__(self, unit):
+ self.unit = unit
+
+ def __str__(self):
+ return 'Invalid glucose unit received:\n%s' % self.unit