-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathboxmaker_exceptions.py
More file actions
36 lines (26 loc) · 1007 Bytes
/
boxmaker_exceptions.py
File metadata and controls
36 lines (26 loc) · 1007 Bytes
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
"""
Custom exceptions for BoxMaker
"""
class BoxMakerError(Exception):
"""Base exception for BoxMaker errors"""
pass
class DimensionError(BoxMakerError):
"""Raised when box dimensions are invalid"""
def __init__(self, dimension_name, value, min_val=None, max_val=None):
self.dimension_name = dimension_name
self.value = value
self.min_val = min_val
self.max_val = max_val
if min_val and value < min_val:
message = f"{dimension_name} ({value}) must be at least {min_val}"
elif max_val and value > max_val:
message = f"{dimension_name} ({value}) must be no more than {max_val}"
else:
message = f"{dimension_name} ({value}) is invalid"
super().__init__(message)
class TabError(BoxMakerError):
"""Raised when tab configuration is invalid"""
pass
class MaterialError(BoxMakerError):
"""Raised when material thickness configuration is invalid"""
pass