
    {i6(                    j   S r SSKJr  SSKJr  SSKJr  SSKJr   " S S\	5      r
 " S	 S
5      r " S S\
5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S \
5      r " S! S"\5      rg#)$aN  PRAW exception classes.

Includes two main exceptions: :class:`.RedditAPIException` for when something goes wrong
on the server side, and :class:`.ClientException` when something goes wrong on the
client side. Both of these classes extend :class:`.PRAWException`.

All other exceptions are subclassed from :class:`.ClientException`.

    )annotations)Any)warn   )_deprecate_argsc                      \ rS rSrSrSrg)PRAWException   z@The base PRAW Exception that all other exception classes extend. N__name__
__module____qualname____firstlineno____doc____static_attributes__r       I/home/james-whalen/.local/lib/python3.13/site-packages/praw/exceptions.pyr	   r	      s    Jr   r	   c                     ^  \ rS rSrSr\SS j5       rSU 4S jjr\" SSS5      SSS	.     SS
 jj5       r	SS jr
SS jrSrU =r$ )RedditErrorItem   z5Represents a single error returned from Reddit's API.c                    U R                   nU R                  (       a  USU R                  < 3-  nU R                  (       a  USU R                  < 3-  nU$ )z'Get the completed error message string.z: z
 on field 
error_typemessagefield)self	error_strs     r   error_messageRedditErrorItem.error_message   sL     OO	<<2dll-..I:::djj^44Ir   c                   > [        U[        5      (       aG  U R                  U R                  U R                  4UR                  UR                  UR                  4:H  $ [
        TU ]  U5      $ )zCheck for equality.)
isinstancer   r   r   r   super__eq__)r   other	__class__s     r   r$   RedditErrorItem.__eq__$   s^    e_--OOT\\4::>  C  
 w~e$$r   r   r   r   N)r   r   c               (    Xl         X0l        X l        g)zInitialize a :class:`.RedditErrorItem` instance.

:param error_type: The error type set on Reddit's end.
:param field: The input field associated with the error, if available.
:param message: The associated message for the error.

Nr   )r   r   r   r   s       r   __init__RedditErrorItem.__init__.   s     %
r   c                    U R                   R                   SU R                  < SU R                  < SU R                  < S3$ )z?Return an object initialization representation of the instance.z(error_type=z
, message=z, field=))r&   r   r   r   r   r   s    r   __repr__RedditErrorItem.__repr__A   sF     ~~&&'|DOO3F G'x

~Q@	
r   c                    U R                   $ )z(Get the message returned from str(self).)r   r-   s    r   __str__RedditErrorItem.__str__H   s    !!!r   r   r   r   returnstr)r%   zRedditErrorItem | list[str]r5   bool)r   r6   r   
str | Noner   r8   )r   r   r   r   r   propertyr   r$   r   r)   r.   r1   r   __classcell__r&   s   @r   r   r      sm    ? % \9g6
 !" 	
  7$
" "r   r   c                      \ rS rSrSrSrg)ClientExceptionM   zEIndicate exceptions that don't involve interaction with Reddit's API.r   Nr   r   r   r   r=   r=   M   s    Or   r=   c                  ,   ^  \ rS rSrSrU 4S jrSrU =r$ )DuplicateReplaceExceptionQ   zKIndicate exceptions that involve the replacement of :class:`.MoreComments`.c                $   > [         TU ]  S5        g)z:Initialize a :class:`.DuplicateReplaceException` instance.ziA duplicate comment has been detected. Are you attempting to call 'replace_more_comments' more than once?Nr#   r)   r   r&   s    r   r)   "DuplicateReplaceException.__init__T   s    7	
r   r   r   r   r   r   r   r)   r   r:   r;   s   @r   r@   r@   Q   s    U
 
r   r@   c                  0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )InvalidFlairTemplateID\   z@Indicate exceptions where an invalid flair template ID is given.c                ,   > [         TU ]  SU S35        g)z8Initialize an :class:`.InvalidFlairTemplateID` instance.zThe flair template ID 'zO' is invalid. If you are trying to create a flair, please use the 'add' method.NrC   )r   template_idr&   s     r   r)   InvalidFlairTemplateID.__init___   s!    %k] 3< <	
r   r   )rK   r6   rF   r;   s   @r   rH   rH   \   s    J
 
r   rH   c                  ,   ^  \ rS rSrSrU 4S jrSrU =r$ )InvalidImplicitAuthg   zDIndicate exceptions where an implicit auth type is used incorrectly.c                $   > [         TU ]  S5        g)z5Initialize an :class:`.InvalidImplicitAuth` instance.z<Implicit authorization can only be used with installed apps.NrC   rD   s    r   r)   InvalidImplicitAuth.__init__j   s    WXr   r   rF   r;   s   @r   rN   rN   g   s    NY Yr   rN   c                  P   ^  \ rS rSrSr\" SS5      SS.S	U 4S jjj5       rSrU =r$ )

InvalidURLo   z4Indicate exceptions where an invalid URL is entered.urlr   zInvalid URL: {})r   c               B   > [         TU ]  UR                  U5      5        g)zInitialize an :class:`.InvalidURL` instance.

:param url: The invalid URL.
:param message: The message to display. Must contain a format identifier (``{}``
    or ``{0}``) (default: ``"Invalid URL: {}"``).

N)r#   r)   format)r   rU   r   r&   s      r   r)   InvalidURL.__init__r   s     	,-r   r   )rU   r6   r   r6   	r   r   r   r   r   r   r)   r   r:   r;   s   @r   rS   rS   o   s'    >UI&3D . . '.r   rS   c                      \ rS rSrSrSrg)!MissingRequiredAttributeException~   zAIndicate exceptions caused by not including a required attribute.r   Nr   r   r   r   r[   r[   ~   s    Kr   r[   c                      \ rS rSrSrSrg)ReadOnlyException   zJRaised when a method call requires :attr:`.read_only` mode to be disabled.r   Nr   r   r   r   r^   r^      s    Tr   r^   c                  H   ^  \ rS rSrSr\" SS5      SU 4S jj5       rSrU =r$ )TooLargeMediaException   z:Indicate exceptions from uploading media that's too large.maximum_sizeactualc               J   > X l         Xl        [        TU ]  SU SU S35        g)zInitialize a :class:`.TooLargeMediaException` instance.

:param actual: The actual size of the uploaded media.
:param maximum_size: The maximum size of the uploaded media.

z;The media that you uploaded was too large (maximum size is z bytes, uploaded z bytes)N)rc   rd   r#   r)   )r   rd   rc   r&   s      r   r)   TooLargeMediaException.__init__   s2     )I,xw0	
r   )rd   rc   )rd   intrc   rg   rY   r;   s   @r   ra   ra      s    D^X.
 /
r   ra   c                     ^  \ rS rSrSr\SS j5       r\R                  S	S j5       r\R                  S 5       rS
U 4S jjr	Sr
U =r$ )WebSocketException   z0Indicate exceptions caused by use of WebSockets.c                8    [        S[        SS9  U R                  $ )z=Access the ``original_exception`` attribute (now deprecated).zAccessing the attribute 'original_exception' is deprecated. Please rewrite your code in such a way that this attribute does not need to be used. It will be removed in PRAW 8.0.   category
stacklevel)r   DeprecationWarning_original_exceptionr-   s    r   original_exception%WebSocketException.original_exception   s'     	, (	
 '''r   c                    Xl         g Nrq   )r   values     r   rr   rs      s    #( r   c                    U ? g ru   rv   r-   s    r   rr   rs      s    $r   c                0   > [         TU ]  U5        X l        g)zInitialize a :class:`.WebSocketException` instance.

:param message: The exception message.
:param exception: The exception thrown by the websocket library.

    .. note::

        This parameter is deprecated. It will be removed in PRAW 8.0.

N)r#   r)   rq   )r   r   	exceptionr&   s      r   r)   WebSocketException.__init__   s     	!#, r   rv   )r5   	Exception)rw   r|   )r   r6   rz   zException | None)r   r   r   r   r   r9   rr   setterdeleterr)   r   r:   r;   s   @r   ri   ri      sV    :	( 	( ) ) %  %- -r   ri   c                  ,   ^  \ rS rSrSrU 4S jrSrU =r$ )MediaPostFailed   z0Indicate exceptions where media uploads failed..c                &   > [         TU ]  SS5        g)z0Initialize a :class:`.MediaPostFailed` instance.zThe attempted media upload action has failed. Possible causes include the corruption of media files. Check that the media file can be opened on your local machine.NrC   rD   s    r   r)   MediaPostFailed.__init__   s    # 		
r   r   rF   r;   s   @r   r   r      s    :
 
r   r   c                     ^  \ rS rSrSr\    S
S j5       r\SS j5       r\SS j5       r	\SS j5       r
    SU 4S jjrSS jrS	rU =r$ )APIException   zOld class preserved for alias purposes.

.. deprecated:: 7.0

    Class :class:`.APIException` has been deprecated in favor of
    :class:`.RedditAPIException`. This class will be removed in PRAW 8.0.

c                    U  Vs/ s HX  n[        U[        5      (       a  UO=[        US   [        US   5      (       a  US   OS[        US   5      (       a  US   OSS9PMZ     sn$ s  snf )z?Covert an exception list into a :class:`.RedditErrorItem` list.r   rl    r   r3   )r"   r   r7   )
exceptionsrz   s     r   parse_exception_list!APIException.parse_exception_list   s~     (
 (	 i99 $(|*.y|*<*<)A,",01,>,>IaLB (
 	
 
s   AA'c                $    U R                  S5      $ )a'  Get error_type.

.. deprecated:: 7.0

    Accessing attributes through instances of :class:`.RedditAPIException` is
    deprecated. This behavior will be removed in PRAW 8.0. Check out the
    :ref:`PRAW 7 Migration tutorial <Exception_Handling>` on how to migrate code
    from this behavior.

r   _get_old_attrr-   s    r   r   APIException.error_type   s     !!,//r   c                $    U R                  S5      $ )a"  Get field.

.. deprecated:: 7.0

    Accessing attributes through instances of :class:`.RedditAPIException` is
    deprecated. This behavior will be removed in PRAW 8.0. Check out the
    :ref:`PRAW 7 Migration tutorial <Exception_Handling>` on how to migrate code
    from this behavior.

r   r   r-   s    r   r   APIException.field   s     !!'**r   c                $    U R                  S5      $ )a$  Get message.

.. deprecated:: 7.0

    Accessing attributes through instances of :class:`.RedditAPIException` is
    deprecated. This behavior will be removed in PRAW 8.0. Check out the
    :ref:`PRAW 7 Migration tutorial <Exception_Handling>` on how to migrate code
    from this behavior.

r   r   r-   s    r   r   APIException.message  s     !!),,r   c                   > [        U[        5      (       a  U/UQ/nO0[        U[        5      (       a  [        US   [        5      (       a  U/nU R                  U5      U l        [
        TU ]  " U R                  6   g)a  Initialize a :class:`.RedditAPIException` instance.

:param items: Either a list of instances of :class:`.RedditErrorItem` or a list
    containing lists of unformed errors.
:param optional_args: Takes the second and third arguments that
    :class:`.APIException` used to take.

r   N)r"   r6   listr   itemsr#   r)   )r   r   optional_argsr&   s      r   r)   APIException.__init__  si     eS!!,m,-Et$$E!Hc)B)BGE..u5
$**%r   c                Z    [        SU S3[        SS9  [        U R                  S   U5      $ )NzAccessing attribute 'z' through APIException is deprecated. This behavior will be removed in PRAW 8.0. Check out https://praw.readthedocs.io/en/latest/package_info/praw7_migration.html to learn how to migrate your code.   rm   r   )r   rp   getattrr   )r   attrnames     r   r   APIException._get_old_attr&  s:    #H: .2 2 (	
 tzz!}h//r   )r   )r   z!list[RedditErrorItem | list[str]]r5   zlist[RedditErrorItem]r4   )r   z-list[RedditErrorItem | list[str] | str] | strr   r6   )r   r6   r5   r   )r   r   r   r   r   staticmethodr   r9   r   r   r   r)   r   r   r:   r;   s   @r   r   r      s     
5
	
 
" 0 0 + + - -&<& &(	0 	0r   r   c                      \ rS rSrSrSrg)RedditAPIExceptioni2  z/Container for error messages from Reddit's API.r   Nr   r   r   r   r   r   2  s    9r   r   N)r   
__future__r   typingr   warningsr   utilr   r|   r	   r   r=   r@   rH   rN   rS   r[   r^   ra   ri   r   r   r   r   r   r   <module>r      s    #   !KI K3" 3"lPm P
 

_ 
Y/ Y. .L LU U
_ 
&#- #-L

( 

c0= c0L: :r   