diff --git a/doc/leaf.adoc b/doc/leaf.adoc index d0407a2..e172b1e 100644 --- a/doc/leaf.adoc +++ b/doc/leaf.adoc @@ -1811,7 +1811,7 @@ leaf::try_handle_all( std::cerr << "Read error!" << std::endl; }, - []( leaf::verbose_diagnostic_info const & info ) <3> + []( leaf::diagnostic_details const & info ) <3> { std::cerr << "Unrecognized error detected, cryptic diagnostic information follows.\n" << info; } ); @@ -1820,14 +1820,13 @@ leaf::try_handle_all( <2> One or more error handlers that should handle all possible failures. <3> This "catch all" error handler is required by `try_handle_all`. It will be called if LEAF is unable to use another error handler. -The `verbose_diagnostic_info` output for the snippet above tells us that we got an `error_code` with value `1` (`write_error`), and an object of type `e_file_name` with `"file.txt"` stored in its `.value`: +The `diagnostic_details` output for the snippet above tells us that we got an `error_code` with value `1` (`write_error`), and an object of type `e_file_name` with `"file.txt"` stored in its `.value`: ---- Unrecognized error detected, cryptic diagnostic information follows. -leaf::verbose_diagnostic_info for Error ID = 1: -[with Name = error_code]: 1 -Unhandled error objects: -[with Name = boost::leaf::e_file_name]: file.txt +leaf::diagnostic_details for Error ID = 1: +error_code: 1 +boost::leaf::e_file_name: file.txt ---- To print each error object, LEAF attempts to bind an unqualified call to `operator<<`, passing a `std::ostream` and the error object. If that fails, it will also attempt to bind `operator<<` that takes the `.value` of the error type. If that also does not compile, the error object value will not appear in diagnostic messages, though LEAF will still print its type. @@ -1849,9 +1848,9 @@ struct e_errno The `e_errno` type above is designed to hold `errno` values. The defined `operator<<` overload will automatically include the output from `strerror` when `e_errno` values are printed (LEAF defines `e_errno` in ``, together with other commonly-used error types). -Using `verbose_diagnostic_info` comes at a cost. Normally, when the program attempts to communicate error objects of types which are not used in any error handling scope in the current call stack, they are discarded, which saves cycles. However, if an error handler is provided that takes `verbose_diagnostic_info` argument, such objects are stored on the heap instead of being discarded. They appear under `Unhandled error objects` in the output from `verbose_diagnostic_info`. +Using `diagnostic_details` comes at a cost. Normally, when the program attempts to communicate error objects of types which are not used in any error handling scope in the current call stack, they are discarded, which saves cycles. However, if an error handler is provided that takes `diagnostic_details` argument, such objects are stored on the heap instead of being discarded. -If handling `verbose_diagnostic_info` is considered too costly, use `diagnostic_info` instead: +If handling `diagnostic_details` is considered too costly, use `diagnostic_info` instead: [source,c++] ---- @@ -1879,7 +1878,7 @@ In this case, the output may look like this: ---- Unrecognized error detected, cryptic diagnostic information follows. leaf::diagnostic_info for Error ID = 1: -[with Name = error_code]: 1 +error_code: 1 ---- Notice how the diagnostic information for `e_file_name` changed: because it was discarded, LEAF is unable to print it. @@ -2680,7 +2679,7 @@ namespace boost { namespace leaf { friend std::ostream & operator<<( std::basic_ostream &, diagnostic_info const & ); }; - class verbose_diagnostic_info: public error_info + class diagnostic_details: public error_info { //No public constructors @@ -2692,7 +2691,7 @@ namespace boost { namespace leaf { ---- [.text-right] -Reference: <> | <> | <> | <> | <> | <> | <> +Reference: <> | <> | <> | <> | <> | <> | <> ==== [[to_variant.hpp]] @@ -3350,7 +3349,7 @@ Requires: :: ** may take arguments, by value, of any predicate type: <>, <>, <>, <>, <>, or of any user-defined predicate type `Pred` for which `<>::value` is `true`; ** may take an <> argument by `const &`; ** may take a <> argument by `const &`; -** may take a <> argument by `const &`. +** may take a <> argument by `const &`. Effects: :: @@ -3495,7 +3494,7 @@ try_handle_some( <2> Print diagnostic information, including limited information about dropped error objects. <3> Return the original error, which will be returned out of `try_handle_some`. + -* If `a~i~` is of type `verbose_diagnostic_info const &`, `try_handle_some` is always able to produce it. +* If `a~i~` is of type `diagnostic_details const &`, `try_handle_some` is always able to produce it. + .Example: [source,c++] @@ -3508,15 +3507,15 @@ try_handle_some( return f(); // throws }, - [](leaf::verbose_diagnostic_info const & info) <1> + [](leaf::diagnostic_details const & info) <1> { - std::cerr << "leaf::verbose_diagnostic_information:" << std::endl << info; <2> + std::cerr << "leaf::diagnostic_details\n" << info; <2> return info.error(); <3> } ); ---- + [.text-right] -<> | <> +<> | <> + <1> This handler matches any error. <2> Print verbose diagnostic information, including values of dropped error objects. @@ -3789,6 +3788,43 @@ For automatic deduction of `Ctx`, use <>. ''' +[[diagnostic_details]] +=== `diagnostic_details` + +.#include +[source,c++] +---- +namespace boost { namespace leaf { + + class diagnostic_details: public error_info + { + //Constructors unspecified + + template + friend std::ostream & operator<<( std::basic_ostream &, diagnostic_details const & ); + }; + +} } +---- + +Handlers passed to error handling functions such as <>, <> or <> may take an argument of type `diagnostic_details const &` if they need to print diagnostic information about the error. + +The message printed by `operator<<` includes the message printed by `error_info`, followed by information about error objects that were communicated to LEAF (to be associated with the error) for which there was no storage available in any active <> (these error objects were discarded by LEAF, because no handler needed them). + +The additional information includes the types and the values of all such error objects. + +[NOTE] +-- +The behavior of `diagnostic_details` (and <>) is affected by the value of the macro `BOOST_LEAF_CFG_DIAGNOSTICS`: + +* If it is 1 (the default), LEAF produces `diagnostic_details` but only if an active error handling context on the call stack takes an argument of type `diagnostic_details`; +* If it is 0, the `diagnostic_details` functionality is stubbed out even for error handling contexts that take an argument of type `diagnostic_details`. This could save some cycles on the error path in some programs (but is probably not worth it). +-- + +WARNING: Using `diagnostic_details` may allocate memory dynamically, but only if an active error handler takes an argument of type `diagnostic_details`. + +''' + [[diagnostic_info]] === `diagnostic_info` @@ -3816,7 +3852,7 @@ The additional information is limited to the type name of the first such error o [NOTE] -- -The behavior of `diagnostic_info` (and <>) is affected by the value of the macro `BOOST_LEAF_CFG_DIAGNOSTICS`: +The behavior of `diagnostic_info` (and <>) is affected by the value of the macro `BOOST_LEAF_CFG_DIAGNOSTICS`: * If it is 1 (the default), LEAF produces `diagnostic_info` but only if an active error handling context on the call stack takes an argument of type `diagnostic_info`; * If it is 0, the `diagnostic_info` functionality is stubbed out even for error handling contexts that take an argument of type `diagnostic_info`. This could shave a few cycles off the error path in some programs (but it is probably not worth it). @@ -4724,43 +4760,6 @@ Requires: :: `*this` must be in <>. Returns :: a reference to the stored value. -''' - -[[verbose_diagnostic_info]] -=== `verbose_diagnostic_info` - -.#include -[source,c++] ----- -namespace boost { namespace leaf { - - class verbose_diagnostic_info: public error_info - { - //Constructors unspecified - - template - friend std::ostream & operator<<( std::basic_ostream &, verbose_diagnostic_info const & ); - }; - -} } ----- - -Handlers passed to error handling functions such as <>, <> or <> may take an argument of type `verbose_diagnostic_info const &` if they need to print diagnostic information about the error. - -The message printed by `operator<<` includes the message printed by `error_info`, followed by information about error objects that were communicated to LEAF (to be associated with the error) for which there was no storage available in any active <> (these error objects were discarded by LEAF, because no handler needed them). - -The additional information includes the types and the values of all such error objects. - -[NOTE] --- -The behavior of `verbose_diagnostic_info` (and <>) is affected by the value of the macro `BOOST_LEAF_CFG_DIAGNOSTICS`: - -* If it is 1 (the default), LEAF produces `verbose_diagnostic_info` but only if an active error handling context on the call stack takes an argument of type `verbose_diagnostic_info`; -* If it is 0, the `verbose_diagnostic_info` functionality is stubbed out even for error handling contexts that take an argument of type `verbose_diagnostic_info`. This could save some cycles on the error path in some programs (but is probably not worth it). --- - -WARNING: Using `verbose_diagnostic_info` may allocate memory dynamically, but only if an active error handler takes an argument of type `verbose_diagnostic_info`. - [[predicates]] == Reference: Predicates @@ -5483,7 +5482,7 @@ Effects: :: `BOOST_LEAF_NEW_ERROR(e...)` is equivalent to `leaf::<>(e The following configuration macros are recognized: -* `BOOST_LEAF_CFG_DIAGNOSTICS`: Defining this macro as `0` stubs out both <> and <> (if the macro is left undefined, LEAF defines it as `1`). +* `BOOST_LEAF_CFG_DIAGNOSTICS`: Defining this macro as `0` stubs out both <> and <> (if the macro is left undefined, LEAF defines it as `1`). * `BOOST_LEAF_CFG_STD_SYSTEM_ERROR`: Defining this macro as `0` disables the `std::error_code` / `std::error_condition` integration. In this case LEAF does not `#include `, which may be too heavy for embedded platforms (if the macro is left undefined, LEAF defines it as `1`). @@ -5493,7 +5492,7 @@ The following configuration macros are recognized: * `BOOST_LEAF_CFG_GNUC_STMTEXPR`: This macro controls whether or not <> is defined in terms of a https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html[GNU C statement expression], which enables its use to check for errors similarly to how the questionmark operator works in some languages (see <>). By default the macro is defined as `1` under `pass:[__GNUC__]`, otherwise as `0`. -* `BOOST_LEAF_CFG_WIN32`: Defining this macro as 1 enables the default constructor in <>, and the automatic conversion to string (via `FormatMessageA`) when <> is printed. If the macro is left undefined, LEAF defines it as `0` (even on windows, since including `windows.h` is generally not desirable). Note that the `e_LastError` type itself is available on all platforms, there is no need for conditional compilation in error handlers that use it. +* `BOOST_LEAF_CFG_WIN32`: Defining this macro as 1 enables the default constructor in <>, and the automatic conversion to string (via `FormatMessageA`) when <> is printed. If the macro is left undefined, LEAF defines it as `0` (even on windows, since including `windows.h` is generally not desirable). Note that the `e_LastError` type itself is available on all platforms, there is no need for conditional compilation in error handlers that use it. * `BOOST_LEAF_NO_EXCEPTIONS`: Disables all exception handling support. If left undefined, LEAF defines it automatically based on the compiler configuration (e.g. `-fno-exceptions`). @@ -5922,7 +5921,7 @@ leaf::try_catch( ==== The fact that Boost Exception stores all supplied `boost::error_info` objects -- while LEAF discards them if they aren't needed -- affects the completeness of the message we get when we print `leaf::<` objects, compared to the string returned by https://www.boost.org/doc/libs/release/libs/exception/doc/diagnostic_information.html[`boost::diagnostic_information`]. -If the user requires a complete diagnostic message, the solution is to use `leaf::<>`. In this case, before unused error objects are discarded by LEAF, they are converted to string and printed. Note that this allocates memory dynamically. +If the user requires a complete diagnostic message, the solution is to use `leaf::<>`. In this case, before unused error objects are discarded by LEAF, they are converted to string and printed. Note that this allocates memory dynamically. ==== ''' diff --git a/example/asio_beast_leaf_rpc.cpp b/example/asio_beast_leaf_rpc.cpp index c6827de..bc94ae7 100644 --- a/example/asio_beast_leaf_rpc.cpp +++ b/example/asio_beast_leaf_rpc.cpp @@ -386,7 +386,7 @@ leaf::result execute_command(std::string_view line) { return response; } -std::string diagnostic_to_str(leaf::verbose_diagnostic_info const &diag) { +std::string diagnostic_to_str(leaf::diagnostic_details const &diag) { auto str = boost::str(boost::format("%1%") % diag); boost::algorithm::replace_all(str, "\n", "\n "); return "\nDetailed error diagnostic:\n----\n" + str + "\n----"; @@ -430,28 +430,28 @@ response_t handle_request(request_t &&request) { // For the rest of error conditions we just build a message to be sent // to the remote client. [&](e_parse_int64_error const &e, e_http_status const *status, e_command const *cmd, - leaf::verbose_diagnostic_info const &diag) { + leaf::diagnostic_details const &diag) { return make_sr(status, boost::str(boost::format("%1% int64 parse error: %2%") % msg_prefix(cmd) % e.value) + diagnostic_to_str(diag)); }, [&](e_unexpected_arg_count const &e, e_http_status const *status, e_command const *cmd, - leaf::verbose_diagnostic_info const &diag) { + leaf::diagnostic_details const &diag) { return make_sr(status, boost::str(boost::format("%1% wrong argument count: %2%") % msg_prefix(cmd) % e.value) + diagnostic_to_str(diag)); }, [&](e_unexpected_http_method const &e, e_http_status const *status, e_command const *cmd, - leaf::verbose_diagnostic_info const &diag) { + leaf::diagnostic_details const &diag) { return make_sr(status, boost::str(boost::format("%1% unexpected HTTP method. Expected: %2%") % msg_prefix(cmd) % e.value) + diagnostic_to_str(diag)); }, [&](std::exception const & e, e_http_status const *status, e_command const *cmd, - leaf::verbose_diagnostic_info const &diag) { + leaf::diagnostic_details const &diag) { return make_sr(status, boost::str(boost::format("%1% %2%") % msg_prefix(cmd) % e.what()) + diagnostic_to_str(diag)); }, - [&](e_http_status const *status, e_command const *cmd, leaf::verbose_diagnostic_info const &diag) { + [&](e_http_status const *status, e_command const *cmd, leaf::diagnostic_details const &diag) { return make_sr(status, boost::str(boost::format("%1% unknown failure") % msg_prefix(cmd)) + diagnostic_to_str(diag)); }); @@ -479,25 +479,25 @@ int main(int argc, char **argv) { [&](std::exception_ptr const &ep, e_last_operation const *op) { return leaf::try_handle_all( [&]() -> leaf::result { std::rethrow_exception(ep); }, - [&](std::exception const & e, leaf::verbose_diagnostic_info const &diag) { + [&](std::exception const & e, leaf::diagnostic_details const &diag) { std::cerr << msg_prefix(op) << e.what() << " (captured)" << diagnostic_to_str(diag) << std::endl; return -11; }, - [&](leaf::verbose_diagnostic_info const &diag) { + [&](leaf::diagnostic_details const &diag) { std::cerr << msg_prefix(op) << "unknown (captured)" << diagnostic_to_str(diag) << std::endl; return -12; }); }, - [&](std::exception const & e, e_last_operation const *op, leaf::verbose_diagnostic_info const &diag) { + [&](std::exception const & e, e_last_operation const *op, leaf::diagnostic_details const &diag) { std::cerr << msg_prefix(op) << e.what() << diagnostic_to_str(diag) << std::endl; return -21; }, - [&](error_code ec, leaf::verbose_diagnostic_info const &diag, e_last_operation const *op) { + [&](error_code ec, leaf::diagnostic_details const &diag, e_last_operation const *op) { std::cerr << msg_prefix(op) << ec << ":" << ec.message() << diagnostic_to_str(diag) << std::endl; return -22; }, - [&](leaf::verbose_diagnostic_info const &diag, e_last_operation const *op) { + [&](leaf::diagnostic_details const &diag, e_last_operation const *op) { std::cerr << msg_prefix(op) << "unknown" << diagnostic_to_str(diag) << std::endl; return -23; }); diff --git a/include/boost/leaf/context.hpp b/include/boost/leaf/context.hpp index 4668006..b0156e7 100644 --- a/include/boost/leaf/context.hpp +++ b/include/boost/leaf/context.hpp @@ -17,7 +17,7 @@ namespace boost { namespace leaf { class error_info; class diagnostic_info; -class verbose_diagnostic_info; +class diagnostic_details; template struct is_predicate: std::false_type @@ -58,7 +58,7 @@ namespace leaf_detail static_assert(!is_predicate::value, "Handlers must take predicate arguments by value"); static_assert(!std::is_same::value, "Handlers must take leaf::error_info arguments by const &"); static_assert(!std::is_same::value, "Handlers must take leaf::diagnostic_info arguments by const &"); - static_assert(!std::is_same::value, "Handlers must take leaf::verbose_diagnostic_info arguments by const &"); + static_assert(!std::is_same::value, "Handlers must take leaf::diagnostic_details arguments by const &"); }; template diff --git a/include/boost/leaf/detail/capture_list.hpp b/include/boost/leaf/detail/capture_list.hpp index a404792..3ad7987 100644 --- a/include/boost/leaf/detail/capture_list.hpp +++ b/include/boost/leaf/detail/capture_list.hpp @@ -94,13 +94,13 @@ namespace leaf_detail } template - void print( std::basic_ostream & os, char const * title, int const err_id_to_print ) const + void print(std::basic_ostream & os, int const err_id_to_print, char const * title = nullptr) const { - BOOST_LEAF_ASSERT(title != nullptr); #if BOOST_LEAF_CFG_DIAGNOSTICS if( first_ ) { - os << title; + if( title ) + os << title; for_each( [&os, err_id_to_print]( node const & n ) { diff --git a/include/boost/leaf/handle_errors.hpp b/include/boost/leaf/handle_errors.hpp index 3e98358..b7b14af 100644 --- a/include/boost/leaf/handle_errors.hpp +++ b/include/boost/leaf/handle_errors.hpp @@ -199,27 +199,27 @@ namespace leaf_detail #if BOOST_LEAF_CFG_CAPTURE -class verbose_diagnostic_info: public diagnostic_info +class diagnostic_details: public diagnostic_info { leaf_detail::dynamic_allocator const * const da_; protected: - verbose_diagnostic_info( verbose_diagnostic_info const & ) noexcept = default; + diagnostic_details( diagnostic_details const & ) noexcept = default; template - BOOST_LEAF_CONSTEXPR verbose_diagnostic_info( error_info const & ei, Tup const & tup, leaf_detail::dynamic_allocator const * da ) noexcept: + BOOST_LEAF_CONSTEXPR diagnostic_details( error_info const & ei, Tup const & tup, leaf_detail::dynamic_allocator const * da ) noexcept: diagnostic_info(ei, tup), da_(da) { } template - friend std::ostream & operator<<( std::basic_ostream & os, verbose_diagnostic_info const & x ) + friend std::ostream & operator<<( std::basic_ostream & os, diagnostic_details const & x ) { os << static_cast(x); if( x.da_ ) - x.da_->print(os, "Unhandled error objects:\n", x.error().value()); + x.da_->print(os, x.error().value()); return os; } }; @@ -256,66 +256,66 @@ namespace leaf_detail return find_in_tuple(t); } - struct verbose_diagnostic_info_: verbose_diagnostic_info + struct diagnostic_details_: diagnostic_details { template - BOOST_LEAF_CONSTEXPR verbose_diagnostic_info_( error_info const & ei, Tup const & tup, dynamic_allocator const * da ) noexcept: - verbose_diagnostic_info(ei, tup, da) + BOOST_LEAF_CONSTEXPR diagnostic_details_( error_info const & ei, Tup const & tup, dynamic_allocator const * da ) noexcept: + diagnostic_details(ei, tup, da) { } }; template <> - struct handler_argument_traits: handler_argument_always_available + struct handler_argument_traits: handler_argument_always_available { template - BOOST_LEAF_CONSTEXPR static verbose_diagnostic_info_ get( Tup const & tup, error_info const & ei ) noexcept + BOOST_LEAF_CONSTEXPR static diagnostic_details_ get( Tup const & tup, error_info const & ei ) noexcept { slot const * da = find_in_tuple>(tup); - return verbose_diagnostic_info_(ei, tup, da ? da->has_value() : nullptr ); + return diagnostic_details_(ei, tup, da ? da->has_value() : nullptr ); } }; } #else -class verbose_diagnostic_info: public diagnostic_info +class diagnostic_details: public diagnostic_info { protected: - verbose_diagnostic_info( verbose_diagnostic_info const & ) noexcept = default; + diagnostic_details( diagnostic_details const & ) noexcept = default; template - BOOST_LEAF_CONSTEXPR verbose_diagnostic_info( error_info const & ei, Tup const & tup ) noexcept: + BOOST_LEAF_CONSTEXPR diagnostic_details( error_info const & ei, Tup const & tup ) noexcept: diagnostic_info(ei, tup) { } template - friend std::ostream & operator<<( std::basic_ostream & os, verbose_diagnostic_info const & x ) + friend std::ostream & operator<<( std::basic_ostream & os, diagnostic_details const & x ) { - return os << "verbose_diagnostic_info not available due to BOOST_LEAF_CFG_CAPTURE=0. Basic diagnostic_info follows.\n" << static_cast(x); + return os << "diagnostic_details not available due to BOOST_LEAF_CFG_CAPTURE=0. Basic diagnostic_info follows.\n" << static_cast(x); } }; namespace leaf_detail { - struct verbose_diagnostic_info_: verbose_diagnostic_info + struct diagnostic_details_: diagnostic_details { template - BOOST_LEAF_CONSTEXPR verbose_diagnostic_info_( error_info const & ei, Tup const & tup ) noexcept: - verbose_diagnostic_info(ei, tup) + BOOST_LEAF_CONSTEXPR diagnostic_details_( error_info const & ei, Tup const & tup ) noexcept: + diagnostic_details(ei, tup) { } }; template <> - struct handler_argument_traits: handler_argument_always_available + struct handler_argument_traits: handler_argument_always_available { template - BOOST_LEAF_CONSTEXPR static verbose_diagnostic_info_ get( Tup const & tup, error_info const & ei ) noexcept + BOOST_LEAF_CONSTEXPR static diagnostic_details_ get( Tup const & tup, error_info const & ei ) noexcept { - return verbose_diagnostic_info_(ei, tup); + return diagnostic_details_(ei, tup); } }; } @@ -324,47 +324,49 @@ namespace leaf_detail #else -class verbose_diagnostic_info: public diagnostic_info +class diagnostic_details: public diagnostic_info { protected: - verbose_diagnostic_info( verbose_diagnostic_info const & ) noexcept = default; + diagnostic_details( diagnostic_details const & ) noexcept = default; - BOOST_LEAF_CONSTEXPR verbose_diagnostic_info( error_info const & ei ) noexcept: + BOOST_LEAF_CONSTEXPR diagnostic_details( error_info const & ei ) noexcept: diagnostic_info(ei) { } template - friend std::ostream & operator<<( std::basic_ostream & os, verbose_diagnostic_info const & x ) + friend std::ostream & operator<<( std::basic_ostream & os, diagnostic_details const & x ) { - return os << "verbose_diagnostic_info not available due to BOOST_LEAF_CFG_DIAGNOSTICS=0. Basic error_info follows.\n" << static_cast(x); + return os << "diagnostic_details not available due to BOOST_LEAF_CFG_DIAGNOSTICS=0. Basic error_info follows.\n" << static_cast(x); } }; namespace leaf_detail { - struct verbose_diagnostic_info_: verbose_diagnostic_info + struct diagnostic_details_: diagnostic_details { - BOOST_LEAF_CONSTEXPR verbose_diagnostic_info_( error_info const & ei ) noexcept: - verbose_diagnostic_info(ei) + BOOST_LEAF_CONSTEXPR diagnostic_details_( error_info const & ei ) noexcept: + diagnostic_details(ei) { } }; template <> - struct handler_argument_traits: handler_argument_always_available + struct handler_argument_traits: handler_argument_always_available { template - BOOST_LEAF_CONSTEXPR static verbose_diagnostic_info_ get( Tup const &, error_info const & ei ) noexcept + BOOST_LEAF_CONSTEXPR static diagnostic_details_ get( Tup const &, error_info const & ei ) noexcept { - return verbose_diagnostic_info_(ei); + return diagnostic_details_(ei); } }; } #endif +using verbose_diagnostic_info = diagnostic_details; + //////////////////////////////////////// namespace leaf_detail diff --git a/include/boost/leaf/result.hpp b/include/boost/leaf/result.hpp index 30cb331..3aafbf9 100644 --- a/include/boost/leaf/result.hpp +++ b/include/boost/leaf/result.hpp @@ -597,7 +597,7 @@ public: if( what.kind() == result_discriminant::err_id_capture_list ) { #if BOOST_LEAF_CFG_CAPTURE - cap_.print(os, ". Captured error objects:\n", err_id.value()); + cap_.print(os, err_id.value(), ". Captured error objects:\n"); #else BOOST_LEAF_ASSERT(0); // Possible ODR violation. #endif diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 224d2a3..dda2b4a 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -141,6 +141,7 @@ compile-fail _compile-fail-arg_match_2.cpp ; compile-fail _compile-fail-arg_rvalue_ref.cpp ; compile-fail _compile-fail-BOOST_LEAF_ASSIGN.cpp ; compile-fail _compile-fail-BOOST_LEAF_AUTO.cpp ; +compile-fail _compile-fail-diagnostic_details.cpp ; compile-fail _compile-fail-diagnostic_info.cpp ; compile-fail _compile-fail-error_info.cpp ; compile-fail _compile-fail-exception_1.cpp ; @@ -150,7 +151,6 @@ compile-fail _compile-fail-result_1.cpp ; compile-fail _compile-fail-result_2.cpp ; compile-fail _compile-fail-result_3.cpp ; compile-fail _compile-fail-result_4.cpp ; -compile-fail _compile-fail-verbose_diagnostic_info.cpp ; exe try_capture_all_eh : ../example/try_capture_all_eh.cpp : single:no off:no leaf_debug_capture0:no leaf_release_capture0:no ; exe try_capture_all_result : ../example/try_capture_all_result.cpp : single:no leaf_debug_capture0:no leaf_release_capture0:no leaf_debug_embedded:no leaf_release_embedded:no ; diff --git a/test/_compile-fail-verbose_diagnostic_info.cpp b/test/_compile-fail-diagnostic_details.cpp similarity index 72% rename from test/_compile-fail-verbose_diagnostic_info.cpp rename to test/_compile-fail-diagnostic_details.cpp index fdbc0c9..5600462 100644 --- a/test/_compile-fail-verbose_diagnostic_info.cpp +++ b/test/_compile-fail-diagnostic_details.cpp @@ -7,6 +7,6 @@ namespace leaf = boost::leaf; -leaf::verbose_diagnostic_info f(); -leaf::verbose_diagnostic_info a = f(); -leaf::verbose_diagnostic_info b = a; +leaf::diagnostic_details f(); +leaf::diagnostic_details a = f(); +leaf::diagnostic_details b = a; diff --git a/test/context_deduction_test.cpp b/test/context_deduction_test.cpp index 33c7c7f..594c449 100644 --- a/test/context_deduction_test.cpp +++ b/test/context_deduction_test.cpp @@ -139,9 +139,9 @@ void not_called_on_purpose() test< std::tuple,info<2>> >( expd([]( info<1>, info<2>, leaf::diagnostic_info const & ){ }, []( info<1>, info<2> ){ }) ); #if BOOST_LEAF_CFG_DIAGNOSTICS && BOOST_LEAF_CFG_CAPTURE - test< std::tuple,info<2>,leaf::leaf_detail::dynamic_allocator> >( expd([]( info<1>, info<2>, leaf::verbose_diagnostic_info const & ){ }, []( info<1>, info<2> ){ }) ); + test< std::tuple,info<2>,leaf::leaf_detail::dynamic_allocator> >( expd([]( info<1>, info<2>, leaf::diagnostic_details const & ){ }, []( info<1>, info<2> ){ }) ); #else - test< std::tuple,info<2>> >( expd([]( info<1>, info<2> ){ }, []( info<1>, leaf::verbose_diagnostic_info const &, info<2> ){ }) ); + test< std::tuple,info<2>> >( expd([]( info<1>, info<2> ){ }, []( info<1>, leaf::diagnostic_details const &, info<2> ){ }) ); #endif { diff --git a/test/ctx_handle_all_test.cpp b/test/ctx_handle_all_test.cpp index 03a77ba..451af3c 100644 --- a/test/ctx_handle_all_test.cpp +++ b/test/ctx_handle_all_test.cpp @@ -31,7 +31,7 @@ leaf::result f( Ctx & ctx ) int main() { - leaf::context, leaf::verbose_diagnostic_info const &> ctx; + leaf::context, leaf::diagnostic_details const &> ctx; { leaf::result r1 = f(ctx); @@ -44,7 +44,7 @@ int main() BOOST_TEST(x.value==1); return 1; }, - []( leaf::verbose_diagnostic_info const & info ) + []( leaf::diagnostic_details const & info ) { std::cout << info; return 2; diff --git a/test/ctx_remote_handle_all_test.cpp b/test/ctx_remote_handle_all_test.cpp index 50ba9ed..3180fb3 100644 --- a/test/ctx_remote_handle_all_test.cpp +++ b/test/ctx_remote_handle_all_test.cpp @@ -37,7 +37,7 @@ int main() BOOST_TEST(x.value==1); return 1; }, - []( leaf::verbose_diagnostic_info const & info ) + []( leaf::diagnostic_details const & info ) { std::cout << info; return 2; diff --git a/test/diagnostic_info_test1.cpp b/test/diagnostic_info_test1.cpp index 44028bf..c5e0752 100644 --- a/test/diagnostic_info_test1.cpp +++ b/test/diagnostic_info_test1.cpp @@ -166,7 +166,7 @@ int main() BOOST_ERROR("Bad error dispatch"); } ); - std::cout << __LINE__ << " ---- verbose_diagnostic_info\n"; + std::cout << __LINE__ << " ---- diagnostic_details\n"; leaf::try_handle_all( []() -> leaf::result { @@ -188,7 +188,7 @@ int main() non_printable_info_non_printable_payload, enum_class_payload, leaf::e_errno, - leaf::verbose_diagnostic_info const & di ) + leaf::diagnostic_details const & di ) { #if BOOST_LEAF_CFG_STD_STRING std::ostringstream st; @@ -207,17 +207,16 @@ int main() BOOST_TEST_EQ(s.find("dynamic_allocator"), s.npos); if( BOOST_LEAF_CFG_CAPTURE ) { - BOOST_TEST_NE(s.find("Unhandled error objects:"), s.npos); BOOST_TEST_NE(s.find("unexpected_test<1>"), s.npos); BOOST_TEST_NE(s.find("unexpected_test<2>"), s.npos); BOOST_TEST_NE(s.find(": 1"), s.npos); BOOST_TEST_NE(s.find(": 2"), s.npos); } else - BOOST_TEST_NE(s.find("verbose_diagnostic_info not available due to BOOST_LEAF_CFG_CAPTURE=0"), s.npos); + BOOST_TEST_NE(s.find("diagnostic_details not available due to BOOST_LEAF_CFG_CAPTURE=0"), s.npos); } else - BOOST_TEST_NE(s.find("verbose_diagnostic_info not available due to BOOST_LEAF_CFG_DIAGNOSTICS=0"), s.npos); + BOOST_TEST_NE(s.find("diagnostic_details not available due to BOOST_LEAF_CFG_DIAGNOSTICS=0"), s.npos); #endif }, []() @@ -308,7 +307,7 @@ int main() #endif } ); - std::cout << __LINE__ << " ---- verbose_diagnostic_info\n"; + std::cout << __LINE__ << " ---- diagnostic_details\n"; leaf::try_catch( [] { @@ -330,7 +329,7 @@ int main() non_printable_info_non_printable_payload, enum_class_payload, leaf::e_errno, - leaf::verbose_diagnostic_info const & di ) + leaf::diagnostic_details const & di ) { #if BOOST_LEAF_CFG_STD_STRING std::ostringstream st; @@ -351,17 +350,16 @@ int main() BOOST_TEST_EQ(s.find("dynamic_allocator"), s.npos); if( BOOST_LEAF_CFG_CAPTURE ) { - BOOST_TEST_NE(s.find("Unhandled error objects:"), s.npos); BOOST_TEST_NE(s.find("unexpected_test<1>"), s.npos); BOOST_TEST_NE(s.find("unexpected_test<2>"), s.npos); BOOST_TEST_NE(s.find(": 1"), s.npos); BOOST_TEST_NE(s.find(": 2"), s.npos); } else - BOOST_TEST_NE(s.find("verbose_diagnostic_info not available due to BOOST_LEAF_CFG_CAPTURE=0"), s.npos); + BOOST_TEST_NE(s.find("diagnostic_details not available due to BOOST_LEAF_CFG_CAPTURE=0"), s.npos); } else - BOOST_TEST_NE(s.find("verbose_diagnostic_info not available due to BOOST_LEAF_CFG_DIAGNOSTICS=0"), s.npos); + BOOST_TEST_NE(s.find("diagnostic_details not available due to BOOST_LEAF_CFG_DIAGNOSTICS=0"), s.npos); #endif } ); diff --git a/test/diagnostic_info_test2.cpp b/test/diagnostic_info_test2.cpp index 8c9c0f1..8641b00 100644 --- a/test/diagnostic_info_test2.cpp +++ b/test/diagnostic_info_test2.cpp @@ -52,7 +52,7 @@ int main() { } ); }, - []( leaf::verbose_diagnostic_info const & di ) + []( leaf::diagnostic_details const & di ) { #if BOOST_LEAF_CFG_STD_STRING std::ostringstream st; @@ -88,7 +88,7 @@ int main() { } ); }, - []( leaf::verbose_diagnostic_info const & di ) + []( leaf::diagnostic_details const & di ) { #if BOOST_LEAF_CFG_STD_STRING std::ostringstream st; @@ -124,7 +124,7 @@ int main() { } ); }, - []( leaf::verbose_diagnostic_info const & di ) + []( leaf::diagnostic_details const & di ) { #if BOOST_LEAF_CFG_STD_STRING std::ostringstream st; diff --git a/test/diagnostic_info_test3.cpp b/test/diagnostic_info_test3.cpp index 5af33bd..83fda71 100644 --- a/test/diagnostic_info_test3.cpp +++ b/test/diagnostic_info_test3.cpp @@ -41,7 +41,7 @@ int main() { return f2(); }, - []( leaf::verbose_diagnostic_info const & di ) + []( leaf::diagnostic_details const & di ) { #if BOOST_LEAF_CFG_STD_STRING std::ostringstream st; diff --git a/test/diagnostic_info_test4.cpp b/test/diagnostic_info_test4.cpp index 5416b09..24948d0 100644 --- a/test/diagnostic_info_test4.cpp +++ b/test/diagnostic_info_test4.cpp @@ -56,7 +56,7 @@ int main() { return f2(); }, - [](leaf::verbose_diagnostic_info const & e) + [](leaf::diagnostic_details const & e) { #if BOOST_LEAF_CFG_STD_STRING std::ostringstream st; diff --git a/test/diagnostic_info_test5.cpp b/test/diagnostic_info_test5.cpp index d945e4f..7a448db 100644 --- a/test/diagnostic_info_test5.cpp +++ b/test/diagnostic_info_test5.cpp @@ -73,7 +73,7 @@ leaf::result f3() { return f2(); }, - []( leaf::verbose_diagnostic_info const & e ) + []( leaf::diagnostic_details const & e ) { return e.error(); } ); @@ -87,7 +87,7 @@ int main() { return f3(); }, - []( info<1> const &, leaf::verbose_diagnostic_info const & di ) + []( info<1> const &, leaf::diagnostic_details const & di ) { #if BOOST_LEAF_CFG_STD_STRING std::ostringstream st; @@ -100,16 +100,10 @@ int main() auto const n2 = s.find("info<2>: acc=0"); auto const n3 = s.find("info<3>: acc=0"); auto const n4 = s.find("info<4>: acc=2"); - auto const nd = s.find("Unhandled"); BOOST_TEST_NE(n1, s.npos); BOOST_TEST_NE(n2, s.npos); BOOST_TEST_NE(n3, s.npos); BOOST_TEST_NE(n4, s.npos); - BOOST_TEST_NE(nd, s.npos); - BOOST_TEST_LT(n1, nd); - BOOST_TEST_GT(n2, nd); - BOOST_TEST_GT(n3, nd); - BOOST_TEST_GT(n4, nd); BOOST_TEST_EQ(counter, 4); } else diff --git a/test/diagnostic_info_test6.cpp b/test/diagnostic_info_test6.cpp index 965c209..457116d 100644 --- a/test/diagnostic_info_test6.cpp +++ b/test/diagnostic_info_test6.cpp @@ -50,7 +50,7 @@ leaf::result f3() { return f1(); }, - [](leaf::verbose_diagnostic_info const &) + [](leaf::diagnostic_details const &) { return leaf::new_error(info<1>{13}); } ); @@ -63,7 +63,7 @@ leaf::result f4() { return f1(); }, - [](leaf::verbose_diagnostic_info const & e) + [](leaf::diagnostic_details const & e) { return e.error().load(info<1>{14}); } ); @@ -75,7 +75,7 @@ int main() { return f2(); }, - [](leaf::verbose_diagnostic_info const & e) + [](leaf::diagnostic_details const & e) { #if BOOST_LEAF_CFG_STD_STRING std::ostringstream st; @@ -95,7 +95,7 @@ int main() { return f3(); }, - [](leaf::verbose_diagnostic_info const & e) + [](leaf::diagnostic_details const & e) { #if BOOST_LEAF_CFG_STD_STRING std::ostringstream st; @@ -115,7 +115,7 @@ int main() { return f4(); }, - [](leaf::verbose_diagnostic_info const & e) + [](leaf::diagnostic_details const & e) { #if BOOST_LEAF_CFG_STD_STRING std::ostringstream st; diff --git a/test/visibility_test.cpp b/test/visibility_test.cpp index f99f4a3..8e1a7ec 100644 --- a/test/visibility_test.cpp +++ b/test/visibility_test.cpp @@ -33,7 +33,7 @@ int main() BOOST_LEAF_CHECK(hidden_result()); return 0; }, - []( my_info<1> x1, my_info<2> x2, leaf::verbose_diagnostic_info const & info, leaf::verbose_diagnostic_info const & vinfo ) + []( my_info<1> x1, my_info<2> x2, leaf::diagnostic_details const & info, leaf::diagnostic_details const & vinfo ) { BOOST_TEST_EQ(x1.value, 1); BOOST_TEST_EQ(x2.value, 2); @@ -64,7 +64,7 @@ int main() hidden_throw(); return 0; }, - []( my_info<1> x1, my_info<2> x2, leaf::verbose_diagnostic_info const & info, leaf::verbose_diagnostic_info const & vinfo ) + []( my_info<1> x1, my_info<2> x2, leaf::diagnostic_details const & info, leaf::diagnostic_details const & vinfo ) { BOOST_TEST_EQ(x1.value, 1); BOOST_TEST_EQ(x2.value, 2);