@@ -11,45 +11,45 @@ exceptions:
11
11
12
12
.. tabularcolumns :: |p{0.5\textwidth}|p{0.45\textwidth}|
13
13
14
- +--------------------------------------+------------------------------+
15
- | C++ exception type | Python exception type |
16
- +======================================+==============================+
17
- | :class: `std::exception ` | ``RuntimeError `` |
18
- +--------------------------------------+------------------------------+
19
- | :class: `std::bad_alloc ` | ``MemoryError `` |
20
- +--------------------------------------+------------------------------+
21
- | :class: `std::domain_error ` | ``ValueError `` |
22
- +--------------------------------------+------------------------------+
23
- | :class: `std::invalid_argument ` | ``ValueError `` |
24
- +--------------------------------------+------------------------------+
25
- | :class: `std::length_error ` | ``ValueError `` |
26
- +--------------------------------------+------------------------------+
27
- | :class: `std::out_of_range ` | ``ValueError `` |
28
- +--------------------------------------+------------------------------+
29
- | :class: `std::range_error ` | ``ValueError `` |
30
- +--------------------------------------+------------------------------+
31
- | :class: `pybind11::stop_iteration ` | ``StopIteration `` (used to |
32
- | | implement custom iterators) |
33
- +--------------------------------------+------------------------------+
34
- | :class: `pybind11::index_error ` | ``IndexError `` (used to |
35
- | | indicate out of bounds |
36
- | | accesses in `` __getitem__ ``, |
37
- | | `` __setitem__ ``, etc.) |
38
- +--------------------------------------+------------------------------+
39
- | :class: ` pybind11::value_error ` | `` ValueError `` (used to |
40
- | | indicate wrong value passed |
41
- | | in `` container.remove(...) `` |
42
- +--------------------------------------+------------------------------+
43
- | :class: ` pybind11::key_error ` | `` KeyError `` (used to |
44
- | | indicate out of bounds |
45
- | | accesses in `` __getitem__ ``, |
46
- | | `` __setitem__ `` in dict-like |
47
- | | objects, etc.) |
48
- +--------------------------------------+------------------------------+
49
- | :class: ` pybind11::error_already_set ` | Indicates that the Python |
50
- | | exception flag has already |
51
- | | been initialized |
52
- +--------------------------------------+------------------------------+
14
+ +--------------------------------------+-------------------------------------- +
15
+ | C++ exception type | Python exception type |
16
+ +======================================+====================================== +
17
+ | :class: `std::exception ` | ``RuntimeError `` |
18
+ +--------------------------------------+-------------------------------------- +
19
+ | :class: `std::bad_alloc ` | ``MemoryError `` |
20
+ +--------------------------------------+-------------------------------------- +
21
+ | :class: `std::domain_error ` | ``ValueError `` |
22
+ +--------------------------------------+-------------------------------------- +
23
+ | :class: `std::invalid_argument ` | ``ValueError `` |
24
+ +--------------------------------------+-------------------------------------- +
25
+ | :class: `std::length_error ` | ``ValueError `` |
26
+ +--------------------------------------+-------------------------------------- +
27
+ | :class: `std::out_of_range ` | ``ValueError `` |
28
+ +--------------------------------------+-------------------------------------- +
29
+ | :class: `std::range_error ` | ``ValueError `` |
30
+ +--------------------------------------+-------------------------------------- +
31
+ | :class: `pybind11::stop_iteration ` | ``StopIteration `` (used to implement |
32
+ | | custom iterators) |
33
+ +--------------------------------------+-------------------------------------- +
34
+ | :class: `pybind11::index_error ` | ``IndexError `` (used to indicate out |
35
+ | | of bounds access in `` __getitem__ ``, |
36
+ | | `` __setitem__ ``, etc.) |
37
+ +--------------------------------------+--------------------------------------+
38
+ | :class: ` pybind11::value_error ` | `` ValueError `` (used to indicate |
39
+ | | wrong value passed in |
40
+ | | `` container.remove(...) ``) |
41
+ +--------------------------------------+--------------------------------------+
42
+ | :class: ` pybind11::key_error ` | `` KeyError `` (used to indicate out |
43
+ | | of bounds access in `` __getitem__ ``, |
44
+ | | `` __setitem__ `` in dict-like |
45
+ | | objects, etc.) |
46
+ +--------------------------------------+--------------------------------------+
47
+ | :class: ` pybind11::error_already_set ` | Indicates that the Python exception |
48
+ | | flag has already been set via Python |
49
+ | | API calls from C++ code; this C++ |
50
+ | | exception is used to propagate such |
51
+ | | a Python exception back to Python. |
52
+ +--------------------------------------+-------------------------------------- +
53
53
54
54
When a Python function invoked from C++ throws an exception, it is converted
55
55
into a C++ exception of type :class: `error_already_set ` whose string payload
0 commit comments