Document verbose_terminate_handler

This commit is contained in:
Peter Dimov 2022-02-15 01:51:15 +02:00
parent 622b7a398a
commit ed84fc4e23
3 changed files with 73 additions and 2 deletions

View File

@ -34,7 +34,7 @@ criteria for inclusion is that the utility component be:
* simple,
* used by other Boost libraries, and
* not dependent on any other Boost modules except Core
itself, Config, Assert, or Static Assert.
itself, Config, Assert, StaticAssert, or ThrowException.
[endsect]
@ -72,3 +72,4 @@ criteria for inclusion is that the utility component be:
[include type_name.qbk]
[include uncaught_exceptions.qbk]
[include use_default.qbk]
[include verbose_terminate_handler.qbk]

View File

@ -0,0 +1,70 @@
[/
Copyright 2022 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://boost.org/LICENSE_1_0.txt
]
[section:verbose_terminate_handler verbose_terminate_handler]
[simplesect Authors]
* Peter Dimov
[endsimplesect]
[section Header <boost/core/verbose_terminate_handler.hpp>]
The header `<boost/core/verbose_terminate_handler.hpp>` defines
the function `void boost::core::verbose_terminate_handler()`. Its
purpose is to be set as a terminate handler as in
```
std::set_terminate( boost::core::verbose_terminate_handler );
```
When invoked, the function prints information about the current
uncaught exception to `stderr` and then calls `std::abort`.
[section Synopsis]
``
namespace boost
{
namespace core
{
[[noreturn]] void verbose_terminate_handler();
} // namespace core
} // namespace boost
``
[endsect]
[section Example]
```
#include <boost/core/verbose_terminate_handler.hpp>
#include <boost/throw_exception.hpp>
#include <exception>
int main()
{
std::set_terminate( boost::core::verbose_terminate_handler );
boost::throw_with_location( std::exception() );
}
```
Sample output:
```
std::terminate called after throwing an exception:
type: class boost::detail::with_throw_location<class std::exception>
what(): Unknown exception
location: example.cpp:8:12 in function 'main'
```
[endsect]
[endsect]
[endsect]

View File

@ -60,7 +60,7 @@ BOOST_NORETURN void verbose_terminate_handler()
boost::source_location loc = boost::get_throw_location( x );
std::fprintf( stderr,
"std::terminate called after throwing an exception:\n"
"std::terminate called after throwing an exception:\n\n"
" type: %s\n"
" what(): %s\n"
" location: %s:%lu:%lu in function '%s'\n",