
    h=$                        d Z ddlZddl 	 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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 G d' d(e      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"y# e$ r" 	 ddlmZ n# e$ r  G d de      ZY nw xY wY 2w xY w)9zExceptions raised by PyMongo.    N)*)SSLCertVerificationError)CertificateErrorc                       e Zd Zy)r   N)__name__
__module____qualname__     Q/var/www/html/ranktracker/api/venv/lib/python3.12/site-packages/pymongo/errors.pyr   r      s    r   r   c                   n     e Zd ZdZd
 fd	Zd Zd Zd Zej                  d   dk(  r
d Z
d	 Z xZS  xZS )PyMongoErrorz&Base class for all PyMongo exceptions.c                 b    t         t        |   |       || _        t	        |xs g       | _        y N)superr   __init___messageset_error_labels)selfmessageerror_labels	__class__s      r   r   zPyMongoError.__init__!   s+    lD*73 !34r   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_label1   s    ""5)r   r      c                     t        | j                  t              r| j                  j                  dd      S t	        | j                        S Nutf-8replaceerrors)
isinstancer   unicodeencodestrr   s    r   __str__zPyMongoError.__str__6   s9    $--1}}++GI+FFt}}%%r   c                 ~    t        | j                  t              r| j                  S t        | j                  dd      S r&   )r+   r   r,   r/   s    r   __unicode__zPyMongoError.__unicode__;   s-    $--1}}$4==')DDr    N)r   r   r	   __doc__r   r   r    r#   sysversion_infor0   r2   __classcell__r   s   @r   r   r      s?    05
+&* a	&
	E  r   r   c                       e Zd ZdZy)ProtocolErrorz1Raised for failures related to the wire protocol.Nr   r   r	   r5   r
   r   r   r;   r;   A   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>   E       Mr   r>   c                   $     e Zd ZdZ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`.
    c                     d }|!t        |t              r|j                  d      }t        t        |   ||       |xs g x| _        | _        y )NerrorLabels)r+   dictgetr   rA   r   r*   details)r   r   r*   r   r   s       r   r   zAutoReconnect.__init__U   sH    *VT":!::m4LmT+G\B%+\r1dlr   r3   r   r   r	   r5   r   r8   r9   s   @r   rA   rA   I   s    
2 2r   rA   c                       e Zd Z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`.
    Nr<   r
   r   r   rI   rI   ]       r   rI   c                     |@| d|} t         j                  d   dk(  r#t        | t              r| j	                  dd      } | S )Nz, full error: r   r$   r'   r(   r)   )r6   r7   r+   r,   r-   )r   rF   s     r   _format_detailed_errorrL   g   sE    *17;A!#
7G(DnnWYn?GNr   c                   $     e Zd ZdZd fd	Z xZS )NotMasterErrora-  The server responded "not master" 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`.
    c                 D    t         t        |   t        ||      |       y )Nr)   )r   rN   r   rL   )r   r   r*   r   s      r   r   zNotMasterError.__init__|   s$    nd,"7F3F 	- 	Dr   r3   rG   r9   s   @r   rN   rN   o   s    D Dr   rN   c                       e Zd Z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.
    Nr<   r
   r   r   rQ   rQ      s    	r   rQ   c                       e Zd ZdZy)ConfigurationErrorz5Raised when something is incorrectly configured.
    Nr<   r
   r   r   rS   rS      s    r   rS   c                   T     e Zd ZdZd fd	Zed        Zed        Zed        Z xZ	S )OperationFailurezmRaised when a database operation fails.

    .. versionadded:: 2.7
       The :attr:`details` attribute.
    c                     d }||j                  d      }t        t        |   t	        ||      |       || _        || _        || _        y )NrC   )r   )rE   r   rU   r   rL   _OperationFailure__code_OperationFailure__details#_OperationFailure__max_wire_version)r   errorcoderF   max_wire_versionr   r   s         r   r   zOperationFailure.__init__   sT    ";;}5L."5'2 	/ 	O "2r   c                     | j                   S r   )rY   r/   s    r   _max_wire_versionz"OperationFailure._max_wire_version   s    &&&r   c                     | j                   S )z7The error code returned by the server, if any.
        )rW   r/   s    r   r[   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.
        )rX   r/   s    r   rF   zOperationFailure.details   s     ~~r   )NNN)
r   r   r	   r5   r   propertyr^   r[   rF   r8   r9   s   @r   rU   rU      sI    3 ' '  
 	 	r   rU   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   rc   rc      s    r   rc   c                       e Zd Z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
    Nr<   r
   r   r   re   re      rJ   r   re   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   rg   rg          r   rg   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   rj   rj      rh   r   rj   c                       e Zd Z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
    Nr<   r
   r   r   rl   rl      s    r   rl   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   rn   rn      r?   r   rn   c                   (     e Zd ZdZ fdZd Z xZS )BulkWriteErrorzFException class for bulk write errors.

    .. versionadded:: 2.7
    c                 0    t         t        |   dd|       y )Nzbatch op errors occurredA   )r   rp   r   )r   resultsr   s     r   r   zBulkWriteError.__init__   s    nd,&G	5r   c                 4    | j                   | j                  ffS r   )r   rF   r/   s    r   
__reduce__zBulkWriteError.__reduce__   s    ~~..r   )r   r   r	   r5   r   ru   r8   r9   s   @r   rp   rp      s    5/r   rp   c                       e Zd ZdZy)InvalidOperationz>Raised when a client attempts to perform an invalid operation.Nr<   r
   r   r   rw   rw      s    Hr   rw   c                       e Zd ZdZy)InvalidNamez$Raised when an invalid name is used.Nr<   r
   r   r   ry   ry      s    .r   ry   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)ExceededMaxWaiterszRaised when a thread tries to get a connection from a pool and
    ``maxPoolSize * waitQueueMultiple`` threads are already waiting.

    .. versionadded:: 2.6
    Nr<   r
   r   r   r   r     s    
 	r   r   c                       e Zd ZdZy)DocumentTooLargezKRaised when an encoded document is too large for the connected server.
    Nr<   r
   r   r   r   r     
    r   r   c                   2     e Zd ZdZ fdZe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                 L    t         t        |   t        |             || _        y r   )r   r   r   r.   _EncryptionError__cause)r   causer   s     r   r   zEncryptionError.__init__   s    ot-c%j9r   c                     | j                   S )z>The exception that caused this encryption or decryption error.)r   r/   s    r   r   zEncryptionError.cause$  s     ||r   )r   r   r	   r5   r   ra   r   r8   r9   s   @r   r   r     s!      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   *  r   r   r   )#r5   r6   bson.errorssslr   r   ImportError
ValueError	Exceptionr   r;   r>   rA   rI   rL   rN   rQ   rS   rU   rc   re   rg   rj   rl   rn   rp   rw   ry   r{   r}   r   InvalidDocumentr   r   r   r
   r   r   <module>r      s   $ 
 @E9 ED<L <N N2% 2(] D] D$
- 
 
%| %R% ' ( ! % N
 N
/% 
/I| I/, /3 3># >	 		 	l &	- 	e  ( 	z 	s5   D E%D,+E,D?<E>D??EE