-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexceptions.py
More file actions
31 lines (27 loc) · 993 Bytes
/
Copy pathexceptions.py
File metadata and controls
31 lines (27 loc) · 993 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
class CustomError(Exception):
"""Base class for other exceptions."""
pass
class ValidationError(CustomError):
"""Raised when a validation error occurs."""
def __init__(self, message, field):
self.message = message
self.field = field
super().__init__(self.message)
class DatabaseError(CustomError):
"""Raised for database related issues."""
def __init__(self, message, query):
self.message = message
self.query = query
super().__init__(self.message)
class NotFoundError(CustomError):
"""Raised when a resource is not found."""
def __init__(self, resource):
self.resource = resource
self.message = f'{resource} not found'
super().__init__(self.message)
class TimeoutError(CustomError):
"""Raised when an operation exceeds time limits."""
def __init__(self, message, duration):
self.message = message
self.duration = duration
super().__init__(self.message)