MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / OperationFailure

Class OperationFailure

pymongo/errors.py:176–221  ·  view source on GitHub ↗

Raised when a database operation fails. .. versionadded:: 2.7 The :attr:`details` attribute.

Source from the content-addressed store, hash-verified

174
175
176class OperationFailure(PyMongoError):
177 """Raised when a database operation fails.
178
179 .. versionadded:: 2.7
180 The :attr:`details` attribute.
181 """
182
183 def __init__(
184 self,
185 error: str,
186 code: Optional[int] = None,
187 details: Optional[Mapping[str, Any]] = None,
188 max_wire_version: Optional[int] = None,
189 ) -> None:
190 error_labels = None
191 if details is not None:
192 error_labels = details.get("errorLabels")
193 super().__init__(_format_detailed_error(error, details), error_labels=error_labels)
194 self.__code = code
195 self.__details = details
196 self.__max_wire_version = max_wire_version
197
198 @property
199 def _max_wire_version(self) -> Optional[int]:
200 return self.__max_wire_version
201
202 @property
203 def code(self) -> Optional[int]:
204 """The error code returned by the server, if any."""
205 return self.__code
206
207 @property
208 def details(self) -> Optional[Mapping[str, Any]]:
209 """The complete error document returned by the server.
210
211 Depending on the error that occurred, the error document
212 may include useful information beyond just the error
213 message. When connected to a mongos the error document
214 may contain one or more subdocuments if errors occurred
215 on multiple shards.
216 """
217 return self.__details
218
219 @property
220 def timeout(self) -> bool:
221 return self.__code in (50,)
222
223
224class CursorNotFound(OperationFailure):

Callers 15

callbackMethod · 0.90
callbackMethod · 0.90
_check_command_responseFunction · 0.90
_raise_bulk_write_errorFunction · 0.90
raw_responseMethod · 0.90
_process_resultMethod · 0.90
_authenticate_scramFunction · 0.90

Calls

no outgoing calls

Tested by 6

callbackMethod · 0.72
callbackMethod · 0.72