forked from aws-powertools/powertools-lambda-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexceptions.py
85 lines (59 loc) · 1.87 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"""
Idempotency errors
"""
from typing import Optional, Union
class BaseError(Exception):
"""
Base error class that overwrites the way exception and extra information is printed.
See https://github.com/aws-powertools/powertools-lambda-python/issues/1772
"""
def __init__(self, *args: Optional[Union[str, Exception]]):
self.message = str(args[0]) if args else ""
self.details = "".join(str(arg) for arg in args[1:]) if args[1:] else None
def __str__(self):
"""
Return all arguments formatted or original message
"""
if self.message and self.details:
return f"{self.message} - ({self.details})"
return self.message
class IdempotencyItemAlreadyExistsError(BaseError):
"""
Item attempting to be inserted into persistence store already exists and is not expired
"""
class IdempotencyItemNotFoundError(BaseError):
"""
Item does not exist in persistence store
"""
class IdempotencyAlreadyInProgressError(BaseError):
"""
Execution with idempotency key is already in progress
"""
class IdempotencyInvalidStatusError(BaseError):
"""
An invalid status was provided
"""
class IdempotencyValidationError(BaseError):
"""
Payload does not match stored idempotency record
"""
class IdempotencyInconsistentStateError(BaseError):
"""
State is inconsistent across multiple requests to persistence store
"""
class IdempotencyPersistenceLayerError(BaseError):
"""
Unrecoverable error from the data store
"""
class IdempotencyKeyError(BaseError):
"""
Payload does not contain an idempotent key
"""
class IdempotencyModelTypeError(BaseError):
"""
Model type does not match expected payload output
"""
class IdempotencyNoSerializationModelError(BaseError):
"""
No model was supplied to the serializer
"""