Skip to content

Commit 0f0d6e0

Browse files
Document error_message_with_prefix
1 parent 227f4df commit 0f0d6e0

2 files changed

Lines changed: 39 additions & 6 deletions

File tree

docs/source/data-structures/misc/libsemigroups-error.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ Exceptions
1111
==========
1212

1313
This page describes the custom error type used in ``libsemigroups_pybind11``,
14-
namely :any:`LibsemigroupsError`. Other built-in exceptions, such as
15-
:any:`ValueError` and :any:`TypeError`, may also be raised in this project. See
16-
the `Python documentation <https://docs.python.org/3/library/exceptions.html>`_
14+
namely :any:`LibsemigroupsError`, and related functions. Other built-in
15+
exceptions, such as :any:`ValueError` and :any:`TypeError`, may also be raised
16+
in this project. See the
17+
`Python documentation <https://docs.python.org/3/library/exceptions.html>`_
1718
for further details.
1819

20+
Full API
21+
--------
22+
1923
.. autoexception:: LibsemigroupsError
2024
:show-inheritance:
2125

@@ -43,3 +47,5 @@ for further details.
4347
but you think it should, please let us known by opening an issue on the
4448
`issue tracker
4549
<https://github.com/libsemigroups/libsemigroups_pybind11/issues>`_.
50+
51+
.. autofunction:: error_message_with_prefix

src/errors.cpp

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,37 @@ namespace libsemigroups {
7676
formatted_error_message(e).c_str());
7777
}
7878
});
79-
// TODO: Doc
79+
8080
m.def("error_message_with_prefix",
81-
py::overload_cast<>(&error_message_with_prefix));
81+
py::overload_cast<>(&error_message_with_prefix),
82+
R"pbdoc(
83+
Return whether :any:`LibsemigroupsError` messages have a C++ prefix.
84+
85+
Since ``libsemigroups_pybind11`` is built on top of the C++ library
86+
``libsemigroups``, many of the errors thrown in ``libsemigroups_pybind11``
87+
emanate from a C++ function. This function returns whether
88+
:any:`LibsemigroupsError` messages contain a prefix that indicates which C++
89+
function raised the exception.
90+
91+
:return: Whether :any:`LibsemigroupsError` messages contain a prefix about the
92+
C++ function that raised the exception.
93+
:rtype: bool
94+
)pbdoc");
8295
m.def("error_message_with_prefix",
83-
py::overload_cast<bool>(&error_message_with_prefix));
96+
py::overload_cast<bool>(&error_message_with_prefix),
97+
py::arg("val"),
98+
R"pbdoc(
99+
Specify whether :any:`LibsemigroupsError` messages have a C++ prefix.
100+
101+
Since ``libsemigroups_pybind11`` is built on top of the C++ library
102+
``libsemigroups``, many of the errors thrown in ``libsemigroups_pybind11``
103+
emanate from a C++ function. This function specifies whether
104+
:any:`LibsemigroupsError` messages should contain a prefix that indicates which
105+
C++ function raised the exception. By default, this information is not included.
106+
107+
:param val: Whether :any:`LibsemigroupsError` messages should contain a prefix
108+
about the C++ function that raised the exception.
109+
:type val: bool
110+
)pbdoc");
84111
}
85112
} // namespace libsemigroups

0 commit comments

Comments
 (0)