aboutsummaryrefslogtreecommitdiff
path: root/quality_control/errors.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-05-18 10:36:10 +0300
committerFrederick Muriuki Muriithi2022-05-18 10:36:10 +0300
commit582686e030b660f218cb7091aaab3cafa103465d (patch)
treee035d570c0a755031758770f4fcd3b240638e891 /quality_control/errors.py
parent4be0ad66b86e238dd92da191061ffc63bee3d09f (diff)
downloadgn-uploader-582686e030b660f218cb7091aaab3cafa103465d.tar.gz
Return errors when found or None otherwise
This commit adds a number of functions that return the error object when an error is found, or `None` otherwise. It avoids the use of exceptions as control flow constructs.
Diffstat (limited to 'quality_control/errors.py')
-rw-r--r--quality_control/errors.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/quality_control/errors.py b/quality_control/errors.py
index 29a38f9..1eda646 100644
--- a/quality_control/errors.py
+++ b/quality_control/errors.py
@@ -1,5 +1,7 @@
"""Hold exceptions for QC package"""
+from collections import namedtuple
+
class InvalidCellValue(Exception):
"""Raised when a function encounters an invalid value"""
@@ -22,3 +24,9 @@ class ParseError(Exception):
"""Raised if any of the above exceptions are raised"""
def __init__(self, *args):
super().__init__(*args)
+
+InvalidValue = namedtuple(
+ "InvalidValue", ("line_number", "column_number", "value", "message"))
+
+DuplicateHeading = namedtuple(
+ "InvalidValue", ("line_number", "heading", "columns","message"))