
    z	i                         S 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g)a8  
===============================================
Top-level exceptions (:mod:`qiskit.exceptions`)
===============================================

Exceptions
==========

All Qiskit-related exceptions raised by Qiskit are subclasses of the base:

.. autoexception:: QiskitError

.. note::

    Errors that are just general programming errors, such as incorrect typing, may still raise
    standard Python errors such as ``TypeError``.  :exc:`QiskitError` is generally for errors raised
    in usage that is particular to Qiskit.

Many of the Qiskit subpackages define their own more granular error, to help in catching only the
subset of errors you care about.  For example, :mod:`qiskit.circuit` almost exclusively uses
:exc:`.CircuitError`, while both :exc:`.QASM2ExportError` and :exc:`.QASM2ParseError` derive from
:exc:`.QASM2Error` in :mod:`qiskit.qasm2`, which is in turn a type of :exc:`.QiskitError`.

Qiskit has several optional features that depend on other packages that are not required for a
minimal install.  You can read more about those, and ways to check for their presence, in
:mod:`qiskit.utils.optionals`.  Trying to use a feature that requires an optional extra will raise a
particular error, which subclasses both :exc:`QiskitError` and the Python built-in ``ImportError``.

.. autoexception:: MissingOptionalLibraryError

Two more uncommon errors relate to failures in reading user-configuration files, or specifying a
filename that cannot be used:

.. autoexception:: QiskitUserConfigError
.. autoexception:: InvalidFileError


Warnings
========

Some particular features of Qiskit may raise custom warnings.  In general, Qiskit will use built-in
Python warnings (such as :exc:`DeprecationWarning`) when appropriate, but warnings related to
Qiskit-specific functionality will be subtypes of :exc:`QiskitWarning`.

.. autoexception:: QiskitWarning

Related to :exc:`MissingOptionalLibraryError`, in some cases an optional dependency might be found,
but fail to import for some other reason.  In this case, Qiskit will continue as if the dependency
is not present, but will raise :exc:`OptionalDependencyImportWarning` to let you know about it.

.. autoexception:: OptionalDependencyImportWarning

When experimental features are being used, Qiskit will raise :exc:`ExperimentalWarning`.

.. warning::

    Qiskit experimental features can break at any minor release and their API might change without
    previous notification. Their use is not recommended in production.

.. autoexception:: ExperimentalWarning

Filtering warnings
------------------

Python has built-in mechanisms to filter warnings, described in the documentation of the
:mod:`warnings` module.  You can use these subclasses in your warning filters from within Python to
silence warnings you are not interested in.  For example, if you are knowingly using experimental
features and are comfortable that they make break in later versions, you can silence
:exc:`ExperimentalWarning` like this::

    import warnings
    from qiskit.exceptions import ExperimentalWarning

    warnings.filterwarnings("ignore", category=ExperimentalWarning)
    )Optionalc                   2   ^  \ rS rSrSrU 4S jrS rSrU =r$ )QiskitError\   z'Base class for errors raised by Qiskit.c                 n   > [         TU ]  SR                  U5      5        SR                  U5      U l        g)zSet the error message. N)super__init__joinmessage)selfr   	__class__s     K/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/exceptions.pyr
   QiskitError.__init___   s)    '*+xx(    c                 ,    [        U R                  5      $ zReturn the message.reprr   r   s    r   __str__QiskitError.__str__d       DLL!!r   r   )	__name__
__module____qualname____firstlineno____doc__r
   r   __static_attributes____classcell__r   s   @r   r   r   \   s    1)
" "r   r   c                       \ rS rSrSrSrSrg)QiskitUserConfigErrori   z?Raised when an error is encountered reading a user config file.zUser config invalid N)r   r   r   r   r   r   r    r&   r   r   r$   r$   i   s
    I#Gr   r$   c                   d   ^  \ rS rSrSr SS\S\S\\   S\\   SS4
U 4S	 jjjrS\4S
 jrSr	U =r
$ )MissingOptionalLibraryErroro   z+Raised when an optional library is missing.Nlibnamenamepip_installmsgreturnc                    > SU SU S3/nU(       a  UR                  SU S35        U(       a  UR                  SU S35        [        TU ]	  SR                  U5      5        SR                  U5      U l        g)zSet the error message.
Args:
    libname: Name of missing library
    name: Name of class, function, module that uses this library
    pip_install: pip install command, if any
    msg: Descriptive message, if any
zThe 'z' library is required to use 'z'.zYou can install it with 'r   .N)appendr	   r
   r   r   )r   r*   r+   r,   r-   r   r   s         r   r
   $MissingOptionalLibraryError.__init__r   ss     7)#A$rJKNN6{m2FGNNQse1:&'*+xx(r   c                 ,    [        U R                  5      $ r   r   r   s    r   r   #MissingOptionalLibraryError.__str__   r   r   r   )NN)r   r   r   r   r   strr   r
   r   r    r!   r"   s   @r   r(   r(   o   sY    5 `d))"%)4<SM)OWX[})	) )&" " "r   r(   c                       \ rS rSrSrSrg)InvalidFileError   zARaised when the file provided is not valid for the specific task.r&   Nr   r   r   r   r   r    r&   r   r   r7   r7      s    Kr   r7   c                       \ rS rSrSrSrg)QiskitWarning   zFCommon subclass of warnings for Qiskit-specific warnings being raised.r&   Nr9   r&   r   r   r;   r;      s    Pr   r;   c                       \ rS rSrSrSrg)OptionalDependencyImportWarning   z@Raised when an optional library raises errors during its import.r&   Nr9   r&   r   r   r>   r>      s    Jr   r>   c                       \ rS rSrSrSrg)ExperimentalWarning   z2Raised when an experimental feature is being used.r&   Nr9   r&   r   r   rA   rA      s    <r   rA   N)r   typingr   	Exceptionr   r$   ImportErrorr(   r7   UserWarningr;   r>   rA   r&   r   r   <module>rG      sm   JX 
") 
"$K $"+{ "6L{ LQK QKm K=- =r   