-
Notifications
You must be signed in to change notification settings - Fork 12
/
exceptions.py
38 lines (29 loc) · 1.1 KB
/
exceptions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
""" Application-specific errors"""
class ShapeError(Exception):
"""Base exception for shapes."""
def __init__(self, shape, msg=None):
if msg is None:
# Default message
msg = f"An error occured with {shape}"
self.msg = msg
self.shape = shape
class ShapeDetectionError(ShapeError):
"""Shape not found"""
def __init__(self, shape, msg=None):
if msg is None:
# Default message
msg = f"Could not find shape: {shape}"
super(ShapeError, self).__init__(msg)
self.shape = shape
class MultipleShapesError(ShapeDetectionError):
"""Shape not found"""
def __init__(self, shape, msg=None):
if msg is None:
# Default message
msg = f"Multiple {shape}s found. Multiple shape detection is currently unsupported."
super(ShapeDetectionError, self).__init__(msg)
self.shape = shape
class ArgumentCombinationError(Exception):
"""Argument combination not valid."""
def __init__(self, msg='Invalid combination of arguments.'):
super().__init__(msg)