3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-27 06:43:40 +01:00
dft_tools/doc/reference/utilities/exceptions.rst

34 lines
964 B
ReStructuredText
Raw Normal View History

2013-08-30 11:07:39 +02:00
.. highlight:: c
.. _util_exceptions:
Exceptions
=============
2013-08-30 11:07:39 +02:00
TRIQS defines special exceptions, with the following characteristics :
* they derives from std::exceptions
2014-07-23 20:55:41 +02:00
* their method .what() returns :
2014-07-23 20:55:41 +02:00
* the date and time of the exception (useful in long QMC computations...).
* the file and line where the exception occurred
2014-07-23 20:55:41 +02:00
* an additionnal error message (see example below). The error behaves like a std::stringstream, one can accumulate any message
* their method .what() returns :
* a complete stack strace of the C++ code at the exception point, with demangling of the function name (on gcc and clang).
2014-07-23 20:55:41 +02:00
In addition, we provide a TRIQS_RUNTIME_ERROR macro to throw exception easily, Cf example below.
.. warning::
For uniformity, it is highly recommended to use these macros when developing for TRIQS.
Example:
.. triqs_example:: ./exceptions_0.cpp
The exception can of course be caught :
.. triqs_example:: ./exceptions_1.cpp