Skip to content

Commit 9a3044b

Browse files
committed
Merge remote-tracking branch 'origin/stable/0.25' into backport-meta-docs
2 parents fc970a6 + 43ce89f commit 9a3044b

16 files changed

Lines changed: 95 additions & 20 deletions

File tree

docs/apidoc/exceptions.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.. _qiskit-exceptions:
2+
3+
.. automodule:: qiskit.exceptions
4+
:no-members:
5+
:no-inherited-members:
6+
:no-special-members:

docs/apidoc/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ API Reference
4545
utils_mitigation
4646
opflow
4747
algorithms
48+
exceptions

qiskit/algorithms/amplitude_estimators/ae.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,6 @@ def compute_confidence_interval(
458458
The (1 - alpha) confidence interval of the specified kind.
459459
460460
Raises:
461-
AquaError: If 'mle' is not in self._ret.keys() (i.e. `run` was not called yet).
462461
NotImplementedError: If the confidence interval method `kind` is not implemented.
463462
"""
464463
# if statevector simulator the estimate is exact

qiskit/circuit/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,17 @@
348348
.. currentmodule:: qiskit.circuit.random
349349
.. autofunction:: random_circuit
350350
.. currentmodule:: qiskit.circuit
351+
352+
Exceptions
353+
----------
354+
355+
Almost all circuit functions and methods will raise a :exc:`CircuitError` when encountering an error
356+
that is particular to usage of Qiskit (as opposed to regular typing or indexing problems, which will
357+
typically raise the corresponding standard Python error).
358+
359+
.. autoexception:: CircuitError
351360
"""
361+
from .exceptions import CircuitError
352362
from .quantumcircuit import QuantumCircuit
353363
from .classicalregister import ClassicalRegister, Clbit
354364
from .quantumregister import QuantumRegister, Qubit, AncillaRegister, AncillaQubit

qiskit/circuit/exceptions.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,3 @@
1717

1818
class CircuitError(QiskitError):
1919
"""Base class for errors raised while processing a circuit."""
20-
21-
pass

qiskit/dagcircuit/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@
3434
Exceptions
3535
==========
3636
37-
.. autosummary::
38-
:toctree: ../stubs/
39-
40-
DAGCircuitError
37+
.. autoexception:: DAGCircuitError
38+
.. autoexception:: DAGDependencyError
4139
4240
Utilities
4341
=========
@@ -53,5 +51,5 @@
5351
from .dagcircuit import DAGCircuit
5452
from .dagnode import DAGNode, DAGOpNode, DAGInNode, DAGOutNode
5553
from .dagdepnode import DAGDepNode
56-
from .exceptions import DAGCircuitError
54+
from .exceptions import DAGCircuitError, DAGDependencyError
5755
from .dagdependency import DAGDependency

qiskit/exceptions.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,39 @@
1010
# copyright notice, and modified files need to carry a notice indicating
1111
# that they have been altered from the originals.
1212

13-
"""Exceptions for errors raised by Qiskit."""
13+
"""
14+
===============================================
15+
Top-level exceptions (:mod:`qiskit.exceptions`)
16+
===============================================
17+
18+
All Qiskit-related errors raised by Qiskit are subclasses of the base:
19+
20+
.. autoexception:: QiskitError
21+
22+
.. note::
23+
24+
Errors that are just general programming errors, such as incorrect typing, may still raise
25+
standard Python errors such as ``TypeError``. :exc:`QiskitError` is generally for errors raised
26+
in usage that is particular to Qiskit.
27+
28+
Many of the Qiskit subpackages define their own more granular error, to help in catching only the
29+
subset of errors you care about. For example, :mod:`qiskit.circuit` almost exclusively uses
30+
:exc:`.CircuitError`, while both :exc:`.QASM2ExportError` and :exc:`.QASM2ParseError` derive from
31+
:exc:`.QASM2Error` in :mod:`qiskit.qasm2`, which is in turn a type of :exc:`.QiskitError`.
32+
33+
Qiskit has several optional features that depend on other packages that are not required for a
34+
minimal install. You can read more about those, and ways to check for their presence, in
35+
:mod:`qiskit.utils.optionals`. Trying to use a feature that requires an optional extra will raise a
36+
particular error, which subclasses both :exc:`QiskitError` and the Python built-in ``ImportError``.
37+
38+
.. autoexception:: MissingOptionalLibraryError
39+
40+
Two more uncommon errors relate to failures in reading user-configuration files, or specifying a
41+
filename that cannot be used:
42+
43+
.. autoexception:: QiskitUserConfigError
44+
.. autoexception:: InvalidFileError
45+
"""
1446

1547
from typing import Optional
1648

qiskit/extensions/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,21 @@
5353
UCRXGate
5454
UCRYGate
5555
UCRZGate
56+
57+
Exceptions
58+
==========
59+
60+
The additional gates in this module will tend to raise a custom exception when they encounter
61+
problems.
62+
63+
.. autoexception:: ExtensionError
5664
"""
5765

5866
# import all standard gates
5967
from qiskit.circuit.library.standard_gates import *
6068
from qiskit.circuit.barrier import Barrier
6169

70+
from .exceptions import ExtensionError
6271
from .quantum_initializer import (
6372
Initialize,
6473
SingleQubitUnitary,

qiskit/opflow/gradients/circuit_gradients/lin_comb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ def _gradient_states(
712712
parameterized gates to compute the product rule.
713713
714714
Raises:
715-
AquaError: If one of the circuits could not be constructed.
715+
QiskitError: If one of the circuits could not be constructed.
716716
TypeError: If the operators is of unsupported type.
717717
ValueError: If the auxiliary operator preparation fails.
718718
"""
@@ -804,7 +804,7 @@ def _hessian_states(
804804
created per parameterized gates to compute the product rule.
805805
806806
Raises:
807-
AquaError: If one of the circuits could not be constructed.
807+
QiskitError: If one of the circuits could not be constructed.
808808
TypeError: If ``operator`` is of unsupported type.
809809
ValueError: If the auxiliary operator preparation fails.
810810
"""

qiskit/providers/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
.. autoexception:: BackendPropertyError
130130
.. autoexception:: JobError
131131
.. autoexception:: JobTimeoutError
132+
.. autoexception:: BackendConfigurationError
132133
133134
======================
134135
Writing a New Provider

0 commit comments

Comments
 (0)