+\h5dZddlmZddlmZddlmZmZm Z m Z m Z m Z m Z ddlmZer ddlmZddlmZGdd eZGd d eZGd d eZGddeZGddeZGddeZ d?dZGddeZGddeZGddeZGddeZGddeZ Gdd eZ!Gd!d"eZ"Gd#d$eZ#Gd%d&e"Z$Gd'd(e#Z%d@d)Z&Gd*d+eZ'Gd,d-eZ(Gd.d/eZ)Gd0d1eZ*Gd2d3eZ+Gd4d5eZ,Gd6d7eZ-Gd8d9eZ.Gd:d;e.Z/Gd<d=eZ0y>)AzExceptions raised by PyMongo. .. seealso:: This module is compatible with both the synchronous and asynchronous PyMongo APIs. ) annotations)SSLCertVerificationError) TYPE_CHECKINGAnyIterableMappingOptionalSequenceUnion)InvalidDocumentClientBulkWriteResult) _DocumentOutcPeZdZdZddfd Zd dZd dZd dZed dZ xZ S) PyMongoErrorz&Base class for all PyMongo exceptions.cZt||||_t|xsg|_yN)super__init___messageset _error_labels)selfmessage error_labels __class__s Q/root/niggaflix-v3/playground/venv/lib/python3.12/site-packages/pymongo/errors.pyrzPyMongoError.__init__"s) !  !34c||jvS)z[Return True if this error contains the given label. .. versionadded:: 3.7 )rrlabels rhas_error_labelzPyMongoError.has_error_label's ****rc:|jj|y)z"Add the given label to this error.N)raddr s r_add_error_labelzPyMongoError._add_error_label.s u%rc:|jj|y)z'Remove the given label from this error.N)rdiscardr s r_remove_error_labelz PyMongoError._remove_error_label2s ""5)rcy)zSTrue if this error was caused by a timeout. .. versionadded:: 4.2 Frs rtimeoutzPyMongoError.timeout6s rN)rstrrzOptional[Iterable[str]]returnNone)r!r/r0bool)r!r/r0r1r0r2) __name__ __module__ __qualname____doc__rr"r%r(propertyr, __classcell__rs@rrrs.05 +&*rrceZdZdZy) ProtocolErrorz1Raised for failures related to the wire protocol.Nr4r5r6r7r*rrr<r<?s;rr<ceZdZdZy)ConnectionFailurezCRaised when a connection to the database cannot be made or is lost.Nr=r*rrr?r?CMrr?c"eZdZdZeddZy)WaitQueueTimeoutErrorzRaised when an operation times out waiting to checkout a connection from the pool. Subclass of :exc:`~pymongo.errors.ConnectionFailure`. .. versionadded:: 4.2 cyNTr*r+s rr,zWaitQueueTimeoutError.timeoutOrNr3r4r5r6r7r8r,r*rrrBrBGsrrBcHeZdZUdZded<ded< d dfd ZxZS) AutoReconnectaRaised when a connection to the database is lost and an attempt to auto-reconnect will be made. In order to auto-reconnect you must handle this exception, recognizing that the operation which caused it has not necessarily succeeded. Future operations will attempt to open a new connection to the database (and will continue to raise this exception until the first successful connection is made). Subclass of :exc:`~pymongo.errors.ConnectionFailure`. z'Union[Mapping[str, Any], Sequence[Any]]errorsdetailscd}|!t|tr|jd}t||||xsgx|_|_y)N errorLabels) isinstancedictgetrrrIrJ)rrrIrrs rrzAutoReconnect.__init__dsI  &$'%zz-8  ,/%+\r1 dlrr-)rr/rIz1Optional[Union[Mapping[str, Any], Sequence[Any]]]r0r1)r4r5r6r7__annotations__rr9r:s@rrHrHTs?  43 44^b22)Z2 22rrHc"eZdZdZeddZy)NetworkTimeoutaAn operation on an open connection exceeded socketTimeoutMS. The remaining connections in the pool stay open. In the case of a write operation, you cannot know whether it succeeded or failed. Subclass of :exc:`~pymongo.errors.AutoReconnect`. cyrDr*r+s rr,zNetworkTimeout.timeoutxrErNr3rFr*rrrRrRorrRc||d|}|S)Nz, full error: r*)rrJs r_format_detailed_errorrV}sI^G95 Nrc2eZdZdZ d dfd ZxZS)NotPrimaryErroraJThe server responded "not primary" or "node is recovering". These errors result from a query, write, or command. The operation failed because the client thought it was using the primary but the primary has stepped down, or the client thought it was using a healthy secondary but the secondary is stale and trying to recover. The client launches a refresh operation on a background thread, to update its view of the server as soon as possible after throwing this exception. Subclass of :exc:`~pymongo.errors.AutoReconnect`. .. versionadded:: 3.12 c<t|t|||y)N)rI)rrrV)rrrIrs rrzNotPrimaryError.__init__s /@Prr-)rr/rI-Optional[Union[Mapping[str, Any], list[Any]]]r0r1)r4r5r6r7rr9r:s@rrXrXs6  Z^QQ)VQ QQrrXc"eZdZdZeddZy)ServerSelectionTimeoutErrora)Thrown when no MongoDB server is available for an operation If there is no suitable server for an operation PyMongo tries for ``serverSelectionTimeoutMS`` (default 30 seconds) to find one, then throws this exception. For example, it is thrown after attempting an operation when PyMongo cannot connect to any server, or if you attempt an insert into a replica set that has no primary and does not elect one within the timeout window, or if you attempt to query with a Read Preference that the replica set cannot satisfy. cyrDr*r+s rr,z#ServerSelectionTimeoutError.timeoutrErNr3rFr*rrr\r\s rr\ceZdZdZy)ConfigurationErrorz0Raised when something is incorrectly configured.Nr=r*rrr_r_s:rr_ceZdZdZ d dfd Zed dZed dZed dZed dZ xZ S) OperationFailurezmRaised when a database operation fails. .. versionadded:: 2.7 The :attr:`details` attribute. cd}||jd}t| t|||||_||_||_y)NrL)r)rOrrrV_OperationFailure__code_OperationFailure__details#_OperationFailure__max_wire_version)rerrorcoderJmax_wire_versionrrs rrzOperationFailure.__init__sN  ";;}5L /w?l[  "2rc|jSr)rer+s r_max_wire_versionz"OperationFailure._max_wire_versions&&&rc|jS)z.The error code returned by the server, if any.rcr+s rrgzOperationFailure.codes{{rc|jS)aVThe complete error document returned by the server. Depending on the error that occurred, the error document may include useful information beyond just the error message. When connected to a mongos the error document may contain one or more subdocuments if errors occurred on multiple shards. )rdr+s rrJzOperationFailure.detailss~~rc|jdvS)N)2rlr+s rr,zOperationFailure.timeouts{{e##r)NNN) rfr/rg Optional[int]rJOptional[Mapping[str, Any]]rhrpr0r1)r0rp)r0rqr3) r4r5r6r7rr8rjrgrJr,r9r:s@rraras#/3*. 3 3 3- 3 ( 3  3''  $$rraceZdZdZy)CursorNotFoundztRaised while iterating query results if the cursor is invalidated on the server. .. versionadded:: 2.7 Nr=r*rrrsrssrrsc"eZdZdZeddZy)ExecutionTimeoutzRaised when a database operation times out, exceeding the $maxTimeMS set in the query or command option. .. note:: Requires server version **>= 2.6.0** .. versionadded:: 2.7 cyrDr*r+s rr,zExecutionTimeout.timeoutrErNr3rFr*rrrururTrruceZdZdZy)WriteConcernErrorz[Base exception type for errors raised due to write concern. .. versionadded:: 3.0 Nr=r*rrrxrxrrxceZdZdZy) WriteErrorz^Base exception type for errors raised during write operations. .. versionadded:: 3.0 Nr=r*rrr{r{ryrr{c"eZdZdZeddZy) WTimeoutErroraRaised when a database operation times out (i.e. wtimeout expires) before replication completes. With newer versions of MongoDB the `details` attribute may include write concern fields like 'n', 'updatedExisting', or 'writtenTo'. .. versionadded:: 2.7 cyrDr*r+s rr,zWTimeoutError.timeoutrErNr3rFr*rrr}r}srr}ceZdZdZy)DuplicateKeyErrorzCRaised when an insert or update fails due to a duplicate key error.Nr=r*rrrrr@rrcb|jddk(xsd|vxr|djdS)zCReturn True if this writeConcernError doc is a caused by a timeout.rgroerrInfowtimeout)rO)rfs r_wtimeout_errorrs6 99V  " _yE'9'^eI>N>R>RS]>^_rcJeZdZUdZded<dfd ZddZed dZxZ S) BulkWriteErrorzFException class for bulk write errors. .. versionadded:: 2.7 rrJc(t|dd|yNzbatch op errors occurredA)rr)rresultsrs rrzBulkWriteError.__init__$s 3RArc4|j|jffSrrrJr+s r __reduce__zBulkWriteError.__reduce__'~~ ..rc|jjdg}|rt|dry|jjdg}|r|djddk(ryy)NwriteConcernErrorsT writeErrorsrgroF)rJrOr)rwceswerrss rr,zBulkWriteError.timeout*s_|| 4b9 ODH-   3 U2Y]]6*b0r)rrr0r1r0ztuple[Any, Any]r3) r4r5r6r7rPrrr8r,r9r:s@rrrs/ B/  rrceZdZUdZded<ded<d fd Zd dZeddZedd Z edd Z edd Z xZ S)ClientBulkWriteExceptionz3Exception class for client-level bulk write errors.rrJr2verbosec6t|dd|||_yr)rrr)rrrrs rrz!ClientBulkWriteException.__init__>s 3RA rc4|j|jffSrrr+s rrz#ClientBulkWriteException.__reduce__Brrc:|jjddS)zA top-level error that occurred when attempting to communicate with the server or execute the bulk write. This value may not be populated if the exception was thrown due to errors occurring on individual writes. rfNrJrOr+s rrfzClientBulkWriteException.errorEs||..rc:|jjdgS)zWrite concern errors that occurred during the bulk write. This list may have multiple items if more than one server command was required to execute the bulk write. rrr+s rwrite_concern_errorsz-ClientBulkWriteException.write_concern_errorsOs|| 4b99rc:|jjdiS)zErrors that occurred during the execution of individual write operations. This list will contain at most one entry if the bulk write was ordered. rrr+s r write_errorsz%ClientBulkWriteException.write_errorsXs || r22rcddlm}|jjdr||jd|jSy)zoThe results of any successful operations that were performed before the error was encountered. rr anySuccessfulT) acknowledgedhas_verbose_resultsN)pymongo.resultsrrJrOr)rrs rpartial_resultz'ClientBulkWriteException.partial_result`s< : <<  O ,( !$(LL  r)rrrr2r0r1r)r0z Optional[Any])r0z!Optional[list[WriteConcernError]])r0zOptional[list[WriteError]])r0zOptional[ClientBulkWriteResult]) r4r5r6r7rPrrr8rfrrrr9r:s@rrr8sk=  M///::33  rrceZdZdZy)InvalidOperationz>Raised when a client attempts to perform an invalid operation.Nr=r*rrrrpsHrrceZdZdZy) InvalidNamez$Raised when an invalid name is used.Nr=r*rrrrts.rrceZdZdZy)CollectionInvalidz(Raised when collection validation fails.Nr=r*rrrrxs2rrceZdZdZy) InvalidURIz3Raised when trying to parse an invalid mongodb URI.Nr=r*rrrr|s=rrceZdZdZy)DocumentTooLargezFRaised when an encoded document is too large for the connected server.Nr=r*rrrrsPrrcHeZdZdZdfd ZeddZeddZxZS)EncryptionErrorzRaised when encryption or decryption fails. This error always wraps another exception which can be retrieved via the :attr:`cause` property. .. versionadded:: 3.9 cDt|t|||_yr)rrr/_EncryptionError__cause)rcausers rrzEncryptionError.__init__s U$ rc|jS)z>The exception that caused this encryption or decryption error.)rr+s rrzEncryptionError.causes||rcdt|jtr|jjSy)NF)rMrrr,r+s rr,zEncryptionError.timeouts# dllL 1<<'' 'r)r Exceptionr0r1)r0rr3) r4r5r6r7rr8rr,r9r:s@rrrs5rrc6eZdZdZdfd ZeddZxZS)EncryptedCollectionErrorz^Raised when creating a collection with encrypted_fields fails. .. versionadded:: 4.4 c2t||||_yr)rr+_EncryptedCollectionError__encrypted_fields)rrencrypted_fieldsrs rrz!EncryptedCollectionError.__init__s "2rc|jS)aThe encrypted_fields document that allows inferring which data keys are *known* to be created. Note that the returned document is not guaranteed to contain information about *all* of the data keys that were created, for example in the case of an indefinite error like a timeout. Use the `cause` property to determine whether a definite or indefinite error caused this error, and only rely on the accuracy of the encrypted_fields if the error is definite. )rr+s rrz)EncryptedCollectionError.encrypted_fieldss&&&r)rrrMapping[str, Any]r0r1)r0r)r4r5r6r7rr8rr9r:s@rrrs! 3''rrceZdZdZy)_OperationCancelledz;Internal error raised when a socket operation is cancelled.Nr=r*rrrrsErrN)rr/rJrZr0r/)rfrr0r2)1r7 __future__rsslr_CertificateErrortypingrrrrr r r bson.errorsr rrpymongo.typingsrrrr<r?rBrHrRrVrXr\r_rarsrurxr{r}rrrrrrrrrrrrr*rrrs#=SSS'5,9@#>QQl2'',F-Fr