@@ -70,6 +70,13 @@ void serialize(writer & w, E const & e)
7070
7171} } // namespace boost::leaf
7272
73+ struct my_exception { };
74+
75+ struct my_exception_ptr
76+ {
77+ std::exception_ptr value;
78+ };
79+
7380template <int N>
7481struct my_error
7582{
@@ -110,8 +117,6 @@ void leaf_throw()
110117 std::make_error_code (std::errc::invalid_argument) );
111118}
112119
113- struct my_exception { };
114-
115120void throw_ ()
116121{
117122 auto load = leaf::on_error (
@@ -312,17 +317,17 @@ int main()
312317 leaf::try_handle_all (
313318 []() -> leaf::result<void >
314319 {
315- return leaf::new_error (std::make_exception_ptr (std::runtime_error (" test exception" )));
320+ return leaf::new_error (my_exception_ptr{ std::make_exception_ptr (std::runtime_error (" test exception" ))} );
316321 },
317- [&j](leaf::diagnostic_details const & dd, std::exception_ptr *)
322+ [&j](leaf::diagnostic_details const & dd, my_exception_ptr *)
318323 {
319324 nlohmann_writer w (j, dd.error ());
320325 dd.write_to (w);
321326 }
322327 );
323328 std::cout << " std::exception_ptr JSON output:\n " << std::setw (2 ) << j << std::endl;
324329
325- auto const & ep = j[" std::exception_ptr " ];
330+ auto const & ep = j[" my_exception_ptr " ][ " value " ];
326331 std::string type = ep[" typeid.name" ].get <std::string>();
327332 std::string what = ep[" what" ].get <std::string>();
328333 BOOST_TEST (type.find (" std::runtime_error" ) != std::string::npos);
@@ -334,17 +339,17 @@ int main()
334339 leaf::try_handle_all (
335340 []() -> leaf::result<void >
336341 {
337- return leaf::new_error (std::make_exception_ptr (42 ));
342+ return leaf::new_error (my_exception_ptr{ std::make_exception_ptr (42 )} );
338343 },
339- [&j](leaf::diagnostic_details const & dd, std::exception_ptr *)
344+ [&j](leaf::diagnostic_details const & dd, my_exception_ptr *)
340345 {
341346 nlohmann_writer w (j, dd.error ());
342347 dd.write_to (w);
343348 }
344349 );
345350 std::cout << " non-std::exception_ptr JSON output:\n " << std::setw (2 ) << j << std::endl;
346351
347- auto const & ep = j[" std::exception_ptr " ];
352+ auto const & ep = j[" my_exception_ptr " ][ " value " ];
348353 std::string type = ep[" typeid.name" ].get <std::string>();
349354 std::string what = ep[" what" ].get <std::string>();
350355 BOOST_TEST_EQ (type, " <<unknown>>" );
0 commit comments