88
99
1010class PynamoDBException (Exception ):
11- msg : str
12-
1311 """
14- A common exception class
12+ Base class for all PynamoDB exceptions.
1513 """
14+
15+ msg : str
16+
1617 def __init__ (self , msg : Optional [str ] = None , cause : Optional [Exception ] = None ) -> None :
1718 self .msg = msg if msg is not None else self .msg
1819 self .cause = cause
1920 super (PynamoDBException , self ).__init__ (self .msg )
2021
2122 @property
2223 def cause_response_code (self ) -> Optional [str ]:
24+ """
25+ The DynamoDB response code such as:
26+
27+ - ``ConditionalCheckFailedException``
28+ - ``ProvisionedThroughputExceededException``
29+ - ``TransactionCanceledException``
30+
31+ Inspect this value to determine the cause of the error and handle it.
32+ """
2333 return getattr (self .cause , 'response' , {}).get ('Error' , {}).get ('Code' )
2434
2535 @property
2636 def cause_response_message (self ) -> Optional [str ]:
37+ """
38+ The human-readable description of the error returned by DynamoDB.
39+ """
2740 return getattr (self .cause , 'response' , {}).get ('Error' , {}).get ('Message' )
2841
2942
@@ -101,35 +114,37 @@ def __init__(self, table_name: str) -> None:
101114
102115class TransactWriteError (PynamoDBException ):
103116 """
104- Raised when a TransactWrite operation fails
117+ Raised when a :class:`~pynamodb.transactions. TransactWrite` operation fails.
105118 """
106- pass
107119
108120
109121class TransactGetError (PynamoDBException ):
110122 """
111- Raised when a TransactGet operation fails
123+ Raised when a :class:`~pynamodb.transactions. TransactGet` operation fails.
112124 """
113- pass
114125
115126
116127class InvalidStateError (PynamoDBException ):
117128 """
118- Raises when the internal state of an operation context is invalid
129+ Raises when the internal state of an operation context is invalid.
119130 """
120131 msg = "Operation in invalid state"
121132
122133
123134class AttributeDeserializationError (TypeError ):
124135 """
125- Raised when attribute type is invalid
136+ Raised when attribute type is invalid during deserialization.
126137 """
127138 def __init__ (self , attr_name : str , attr_type : str ):
128139 msg = "Cannot deserialize '{}' attribute from type: {}" .format (attr_name , attr_type )
129140 super (AttributeDeserializationError , self ).__init__ (msg )
130141
131142
132143class AttributeNullError (ValueError ):
144+ """
145+ Raised when an attribute which is not nullable (:code:`null=False`) is unset during serialization.
146+ """
147+
133148 def __init__ (self , attr_name : str ) -> None :
134149 self .attr_path = attr_name
135150
@@ -141,8 +156,14 @@ def prepend_path(self, attr_name: str) -> None:
141156
142157
143158class VerboseClientError (botocore .exceptions .ClientError ):
144- def __init__ (self , error_response : Any , operation_name : str , verbose_properties : Optional [Any ] = None ):
145- """ Modify the message template to include the desired verbose properties """
159+ def __init__ (self , error_response : Any , operation_name : str , verbose_properties : Optional [Any ] = None ) -> None :
160+ """
161+ Like ClientError, but with a verbose message.
162+
163+ :param error_response: Error response in shape expected by ClientError.
164+ :param operation_name: The name of the operation that failed.
165+ :param verbose_properties: A dict of properties to include in the verbose message.
166+ """
146167 if not verbose_properties :
147168 verbose_properties = {}
148169
0 commit comments