
    b?iQ                     $   % S r SSKJrJrJr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\
0\\
S.S\0S\	0S\0S.r\\\\\4   4   \S'   S\\\4   S\S\S\4S jr " S S\5      rg)zResend Exceptions module.

This module defines the base types for platform-wide error
codes as outlined in https://resend.com/docs/api-reference/errors.
    )AnyDictNoReturnUnionc                   <    \ rS rSrSrS\\\4   S\S\S\4S jrSr	g	)
ResendError
   aa  Base class for all errors raised by Resend SDK.
This is the parent class of all exceptions (server side)
raised by the Resend SDK. Developers can simply catch
this class and inspect its `code` to implement more specific
error handling. Note that for some client-side errors ie:
some method argument missing, a ValueError would be raised.

Args:
    code: A string error indicating the HTTP status code
    attributed to that Error.
    message: A human-readable error message string.
    suggested_action: A suggested action path to help the user.
    error_type: Maps to the `type` field from the Resend API
code
error_typemessagesuggested_actionc                 ^    [         R                  X5        Xl        X0l        X@l        X l        g )N)	Exception__init__r
   r   r   r   )selfr
   r   r   r   s        U/var/www/html/livechat/backend/venv/lib/python3.13/site-packages/resend/exceptions.pyr   ResendError.__init__   s'     	4)	 0$    )r
   r   r   r   N)
__name__
__module____qualname____firstlineno____doc__r   strintr   __static_attributes__ r   r   r   r   
   s:    %CHo% % 	%
 %r   r   c                   8    \ rS rSrSrS\S\S\\\4   4S jrSr	g)	MissingApiKeyError(   0see https://resend.com/docs/api-reference/errorsr   r   r
   c                 :    SnSn[         R                  U UUUUS9  g )NzWInclude the following header
        Authorization: Bearer YOUR_API_KEY in the request.z,Missing API key in the authorization header.r   r   r
   r   r   r   r   r   r   r
   r   s        r   r   MissingApiKeyError.__init__+   s4    > A-! 	 	
r   r   N
r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   (   s.    :

 
 CHo	
r   r   c                   8    \ rS rSrSrS\S\S\\\4   4S jrSr	g)	InvalidApiKeyError?   r!   r   r   r
   c                 6    Sn[         R                  U UUUUS9  g )Nz(Generate a new API key in the dashboard.r#   r$   r%   s        r   r   InvalidApiKeyError.__init__B   s-     J-! 	 	
r   r   Nr'   r   r   r   r)   r)   ?   s.    :

 
 CHo	
r   r)   c                   8    \ rS rSrSrS\S\S\\\4   4S jrSr	g)	ValidationErrorS   r!   r   r   r
   c                 \    SnSnUS:X  a  Un[         R                  U U=(       d    SUUUS9  g )NA
        The request body is missing one or more required fields.BCheck the error message
        to see the list of missing fields. 400r
   r   r   r   r$   r   r   r   r
   default_messager   s         r   r   ValidationError.__init__V   F    D. b=%G-! 	 	
r   r   Nr'   r   r   r   r.   r.   S   .    :

 
 CHo	
r   r.   c                   8    \ rS rSrSrS\S\S\\\4   4S jrSr	g)	MissingRequiredFieldsErrorn   r!   r   r   r
   c                 \    SnSnUS:X  a  Un[         R                  U U=(       d    SUUUS9  g )Nr1   r2   r3   422r5   r$   r6   s         r   r   #MissingRequiredFieldsError.__init__q   r9   r   r   Nr'   r   r   r   r<   r<   n   r:   r   r<   c                   8    \ rS rSrSrS\S\S\\\4   4S jrSr	g)	ApplicationError   r!   r   r   r
   c                 \    SnSnUS:X  a  Un[         R                  U U=(       d    SUUUS9  g )Nz
        Something went wrong.zContact Resend support.r3   500r5   r$   r6   s         r   r   ApplicationError.__init__   sC    ! 9b=%G-! 	 	
r   r   Nr'   r   r   r   rB   rB      s.    :

 
 CHo	
r   rB   validation_error)missing_required_fieldsrG   missing_api_keyinvalid_api_keyapplication_error)r4   r?   401403rE   ERRORSr
   r   r   returnc                     [         R                  [        U 5      5      nUc  [        XUSS9eUR                  U5      nUb  U" U UUS9e[        XUSS9e)a  Raise the appropriate error based on the code and type.

Args:
    code (str): The error code
    error_type (str): The error type
    message (str): The error message

Raises:
    ResendError: If it is a Resend err
        or
    ValidationError: If the error type is validation_error
        or
    MissingRequiredFieldsError: If the error type is missing_required_fields
        or
    MissingApiKeyError: If the error type is missing_api_key
        or
    InvalidApiKeyError: If the error type is invalid_api_key
        or
    ApplicationError: If the error type is application_error
        or
    TypeError: If the error type is not found
r3   )r
   r   r   r   )r
   r   r   )rN   getr   r   )r
   r   r   errorerror_from_lists        r   raise_for_code_and_typerT      st    2 JJs4y!E }:PR
 	

 ii
+O"!
 	
 zB r   c                   "    \ rS rSrSrSS jrSrg)NoContentError   z'Raised when the response body is empty.Nc                 P    SU l         [        R                  X R                   5        g )NzPNo content was returned from the API.
            Please contact Resend support.)r   r   r   )r   s    r   r   NoContentError.__init__   s    .4.r   )r   )rO   N)r   r   r   r   r   r   r   r   r   r   rV   rV      s
    1/r   rV   N)r   typingr   r   r   r   r   r   r   r)   r.   r<   rB   rN   r   __annotations__r   rT   rV   r   r   r   <module>r\      s    . -%) %<
 
.
 
(
k 
6
 
6
{ 
8 0#=+ 1212!12	%S$sCx. ! 	-
S/-'*-58--`/Y /r   