
    FCf-                       d Z ddlmZ ddlmZ ddlmZmZm	Z	m
Z
mZmZmZ ddlmZ erddlmZ  G d de      Z G d	 d
e      Z G d de      Z G d de      Z G d de      Z G d de      Z	 	 	 	 	 	 d<dZ G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d  d!e      Z  G d" d#e      Z! G d$ d%e       Z" G d& d'e!      Z#d=d(Z$ G d) d*e      Z% G d+ d,e      Z& G d- d.e      Z' G d/ d0e      Z( G d1 d2e      Z) G d3 d4e      Z* G d5 d6e      Z+ G d7 d8e+      Z, G d9 d:e      Z-y;)>zExceptions raised by PyMongo.    )annotations)SSLCertVerificationError)TYPE_CHECKINGAnyIterableMappingOptionalSequenceUnion)InvalidDocument)_DocumentOutc                  P     e Zd ZdZdd fdZd	dZd
dZd
dZedd       Z	 xZ
S )PyMongoErrorz&Base class for all PyMongo exceptions.c                Z    t         |   |       || _        t        |xs g       | _        y N)super__init___messageset_error_labels)selfmessageerror_labels	__class__s      N/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/pymongo/errors.pyr   zPyMongoError.__init__   s)    ! !34    c                    || j                   v S )z[Return True if this error contains the given label.

        .. versionadded:: 3.7
        )r   r   labels     r   has_error_labelzPyMongoError.has_error_label#   s    
 ****r   c                :    | j                   j                  |       y)z"Add the given label to this error.N)r   addr   s     r   _add_error_labelzPyMongoError._add_error_label*   s    u%r   c                :    | j                   j                  |       y)z'Remove the given label from this error.N)r   discardr   s     r   _remove_error_labelz PyMongoError._remove_error_label.   s    ""5)r   c                     y)zSTrue if this error was caused by a timeout.

        .. versionadded:: 4.2
        F r   s    r   timeoutzPyMongoError.timeout2   s     r    N)r   strr   zOptional[Iterable[str]]returnNone)r   r-   r.   bool)r   r-   r.   r/   r.   r0   )__name__
__module____qualname____doc__r   r    r#   r&   propertyr*   __classcell__r   s   @r   r   r      s.    05
+&*  r   r   c                      e Zd ZdZy)ProtocolErrorz1Raised for failures related to the wire protocol.Nr2   r3   r4   r5   r(   r   r   r:   r:   ;   s    ;r   r:   c                      e Zd ZdZy)ConnectionFailurezCRaised when a connection to the database cannot be made or is lost.Nr;   r(   r   r   r=   r=   ?       Mr   r=   c                  "    e Zd ZdZedd       Zy)WaitQueueTimeoutErrorzRaised when an operation times out waiting to checkout a connection from the pool.

    Subclass of :exc:`~pymongo.errors.ConnectionFailure`.

    .. versionadded:: 4.2
    c                     yNTr(   r)   s    r   r*   zWaitQueueTimeoutError.timeoutK       r   Nr1   r2   r3   r4   r5   r6   r*   r(   r   r   r@   r@   C   s      r   r@   c                  H     e Zd ZU dZded<   ded<   	 d	 	 	 	 	 d fdZ xZS )AutoReconnecta  Raised 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]]errorsdetailsc                    d }|!t        |t              r|j                  d      }t        |   ||       |xs g x| _        | _        y )NerrorLabels)
isinstancedictgetr   r   rG   rH   )r   r   rG   r   r   s       r   r   zAutoReconnect.__init__`   sI     &$'%zz-8,/%+\r1dlr   r+   )r   r-   rG   z1Optional[Union[Mapping[str, Any], Sequence[Any]]]r.   r/   )r2   r3   r4   r5   __annotations__r   r7   r8   s   @r   rF   rF   P   s?    
 4344 ^b22)Z2	2 2r   rF   c                  "    e Zd ZdZedd       Zy)NetworkTimeouta  An 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`.
    c                     yrB   r(   r)   s    r   r*   zNetworkTimeout.timeoutt   rC   r   Nr1   rD   r(   r   r   rP   rP   k         r   rP   c                    ||  d| } | S )Nz, full error: r(   )r   rH   s     r   _format_detailed_errorrT   y   s     I^G95Nr   c                  2     e Zd ZdZ	 d	 	 	 	 	 d fdZ xZS )NotPrimaryErroraJ  The 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)rG   )r   r   rT   )r   r   rG   r   s      r   r   zNotPrimaryError.__init__   s     	/@Pr   r+   )r   r-   rG   -Optional[Union[Mapping[str, Any], list[Any]]]r.   r/   )r2   r3   r4   r5   r   r7   r8   s   @r   rV   rV      s6      Z^QQ)VQ	Q Qr   rV   c                  "    e Zd ZdZedd       Zy)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.
    c                     yrB   r(   r)   s    r   r*   z#ServerSelectionTimeoutError.timeout   rC   r   Nr1   rD   r(   r   r   rZ   rZ      s    	  r   rZ   c                      e Zd ZdZy)ConfigurationErrorz0Raised when something is incorrectly configured.Nr;   r(   r   r   r]   r]      s    :r   r]   c                       e Zd ZdZ	 	 	 d	 	 	 	 	 	 	 	 	 d fdZed	d       Zed	d       Zed
d       Zedd       Z	 xZ
S )OperationFailurezmRaised when a database operation fails.

    .. versionadded:: 2.7
       The :attr:`details` attribute.
    c                    d }||j                  d      }t        | 	  t        ||      |       || _        || _        || _        y )NrJ   )r   )rM   r   r   rT   _OperationFailure__code_OperationFailure__details#_OperationFailure__max_wire_version)r   errorcoderH   max_wire_versionr   r   s         r   r   zOperationFailure.__init__   sN     ";;}5L/w?l[ "2r   c                    | j                   S r   )rc   r)   s    r   _max_wire_versionz"OperationFailure._max_wire_version   s    &&&r   c                    | j                   S )z.The error code returned by the server, if any.ra   r)   s    r   re   zOperationFailure.code   s     {{r   c                    | j                   S )aV  The 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.
        )rb   r)   s    r   rH   zOperationFailure.details   s     ~~r   c                    | j                   dv S )N)2   rj   r)   s    r   r*   zOperationFailure.timeout   s    {{e##r   )NNN)
rd   r-   re   Optional[int]rH   Optional[Mapping[str, Any]]rf   rn   r.   r/   )r.   rn   )r.   ro   r1   )r2   r3   r4   r5   r   r6   rh   re   rH   r*   r7   r8   s   @r   r_   r_      s     #/3*.33 3 -	3
 (3 
3 ' '   	 	 $ $r   r_   c                      e Zd ZdZy)CursorNotFoundztRaised while iterating query results if the cursor is
    invalidated on the server.

    .. versionadded:: 2.7
    Nr;   r(   r   r   rq   rq      s    r   rq   c                  "    e Zd ZdZedd       Zy)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
    c                     yrB   r(   r)   s    r   r*   zExecutionTimeout.timeout   rC   r   Nr1   rD   r(   r   r   rs   rs      rR   r   rs   c                      e Zd ZdZy)WriteConcernErrorz[Base exception type for errors raised due to write concern.

    .. versionadded:: 3.0
    Nr;   r(   r   r   rv   rv          r   rv   c                      e Zd ZdZy)
WriteErrorz^Base exception type for errors raised during write operations.

    .. versionadded:: 3.0
    Nr;   r(   r   r   ry   ry      rw   r   ry   c                  "    e Zd ZdZedd       Zy)WTimeoutErrora  Raised 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
    c                     yrB   r(   r)   s    r   r*   zWTimeoutError.timeout
  rC   r   Nr1   rD   r(   r   r   r{   r{      s      r   r{   c                      e Zd ZdZy)DuplicateKeyErrorzCRaised when an insert or update fails due to a duplicate key error.Nr;   r(   r   r   r~   r~     r>   r   r~   c                b    | j                  d      dk(  xs d| v xr | d   j                  d      S )zCReturn True if this writeConcernError doc is a caused by a timeout.re   rm   errInfowtimeout)rM   )rd   s    r   _wtimeout_errorr     s6    99V"_yE'9'^eI>N>R>RS]>^_r   c                  J     e Zd ZU dZded<   d fdZddZed	d       Z xZ	S )
BulkWriteErrorzFException class for bulk write errors.

    .. versionadded:: 2.7
    r   rH   c                (    t         |   dd|       y )Nzbatch op errors occurredA   )r   r   )r   resultsr   s     r   r   zBulkWriteError.__init__   s    3RAr   c                4    | j                   | j                  ffS r   )r   rH   r)   s    r   
__reduce__zBulkWriteError.__reduce__#  s    ~~..r   c                    | j                   j                  dg       }|rt        |d         ry| j                   j                  dg       }|r|d   j                  d      dk(  ryy)NwriteConcernErrorsTwriteErrorsre   rm   F)rH   rM   r   )r   wceswerrss      r   r*   zBulkWriteError.timeout&  s_     || 4b9ODH-  3U2Y]]6*b0r   )r   r   r.   r/   )r.   ztuple[Any, Any]r1   )
r2   r3   r4   r5   rN   r   r   r6   r*   r7   r8   s   @r   r   r     s/    
 B/ 
 
r   r   c                      e Zd ZdZy)InvalidOperationz>Raised when a client attempts to perform an invalid operation.Nr;   r(   r   r   r   r   4  s    Hr   r   c                      e Zd ZdZy)InvalidNamez$Raised when an invalid name is used.Nr;   r(   r   r   r   r   8  s    .r   r   c                      e Zd ZdZy)CollectionInvalidz(Raised when collection validation fails.Nr;   r(   r   r   r   r   <  s    2r   r   c                      e Zd ZdZy)
InvalidURIz3Raised when trying to parse an invalid mongodb URI.Nr;   r(   r   r   r   r   @  s    =r   r   c                      e Zd ZdZy)DocumentTooLargezFRaised when an encoded document is too large for the connected server.Nr;   r(   r   r   r   r   D  s    Pr   r   c                  H     e Zd ZdZd fdZedd       Zedd       Z xZS )EncryptionErrorzRaised when encryption or decryption fails.

    This error always wraps another exception which can be retrieved via the
    :attr:`cause` property.

    .. versionadded:: 3.9
    c                D    t         |   t        |             || _        y r   )r   r   r-   _EncryptionError__cause)r   causer   s     r   r   zEncryptionError.__init__Q  s    U$r   c                    | j                   S )z>The exception that caused this encryption or decryption error.)r   r)   s    r   r   zEncryptionError.causeU  s     ||r   c                d    t        | j                  t              r| j                  j                  S y)NF)rK   r   r   r*   r)   s    r   r*   zEncryptionError.timeoutZ  s#    dllL1<<'''r   )r   	Exceptionr.   r/   )r.   r   r1   )	r2   r3   r4   r5   r   r6   r   r*   r7   r8   s   @r   r   r   H  s5        r   r   c                  6     e Zd ZdZd fdZedd       Z xZS )EncryptedCollectionErrorz^Raised when creating a collection with encrypted_fields fails.

    .. versionadded:: 4.4
    c                2    t         |   |       || _        y r   )r   r   +_EncryptedCollectionError__encrypted_fields)r   r   encrypted_fieldsr   s      r   r   z!EncryptedCollectionError.__init__g  s    "2r   c                    | j                   S )a  The 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.
        )r   r)   s    r   r   z)EncryptedCollectionError.encrypted_fieldsk  s     &&&r   )r   r   r   Mapping[str, Any]r.   r/   )r.   r   )r2   r3   r4   r5   r   r6   r   r7   r8   s   @r   r   r   a  s!    
3 ' 'r   r   c                      e Zd ZdZy)_OperationCancelledz;Internal error raised when a socket operation is cancelled.Nr;   r(   r   r   r   r   w  s    Er   r   N)r   r-   rH   rX   r.   r-   )rd   r   r.   r0   ).r5   
__future__r   sslr   _CertificateErrortypingr   r   r   r   r	   r
   r   bson.errorsr   pymongo.typingsr   r   r   r:   r=   r@   rF   rP   rT   rV   rZ   r]   r_   rq   rs   rv   ry   r{   r~   r   r   r   r   r   r   r   r   r   r   r(   r   r   <module>r      s   $ " = S S S ',9 @<L <N N
- 
2% 26] HQm Q,- "; ;-$| -$`% ' ( ! % N
 N`
% 8I| I/, /3 3># >Q Ql 2' ',F- Fr   