
    rVi                     h    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y
)    )Sequencec                       e Zd Zy)BaseLibp2pErrorN__name__
__module____qualname__     4/Users/sumanjeet/code/py-libp2p/libp2p/exceptions.pyr   r          r   r   c                       e Zd ZdZy)ValidationErrorz7Raised when something does not pass a validation check.N)r   r   r	   __doc__r
   r   r   r   r   
   s    Ar   r   c                       e Zd Zy)
ParseErrorNr   r
   r   r   r   r      r   r   r   c                   >     e Zd ZdZdee   ddf fdZdefdZ xZ	S )
MultiErroraz  
    A combined error that wraps multiple exceptions into a single error object.
    This error is raised when multiple exceptions need to be reported together,
    typically in scenarios where parallel operations or multiple validations fail.

    Example\:
    ---------
        >>> from libp2p.exceptions import MultiError
        >>> errors = [
        ...     ValueError("Invalid input"),
        ...     TypeError("Wrong type"),
        ...     RuntimeError("Operation failed")
        ... ]
        >>> multi_error = MultiError(errors)
        >>> print(multi_error)
        Error 1: Invalid input
        Error 2: Wrong type
        Error 3: Operation failed

    Note\:
    ------
        The string representation of this error will number and list all contained
        errors sequentially, making it easier to identify individual issues in
        complex error scenarios.

    errorsreturnNc                 2    t         |   |       || _        y )N)super__init__r   )selfr   	__class__s     r   r   zMultiError.__init__.   s     r   c                 X    dj                  d t        | j                        D              S )N
c              3   8   K   | ]  \  }}d |dz    d|   yw)zError    z: Nr
   ).0ierrors      r   	<genexpr>z%MultiError.__str__.<locals>.<genexpr>3   s*      
*2!UfQUG2eW%
s   )join	enumerater   )r   s    r   __str__zMultiError.__str__2   s)    yy 
6?6L
 
 	
r   )
r   r   r	   r   r   	Exceptionr   strr&   __classcell__)r   s   @r   r   r      s,    6x	2 t 
 
r   r   N)collections.abcr   r'   r   r   r   r   r
   r   r   <module>r+      s<   
	i 	Bo B	 	#
 #
r   