diff --git a/include/boost/leaf/all.hpp b/include/boost/leaf/all.hpp index e14e59f..c0345f2 100644 --- a/include/boost/leaf/all.hpp +++ b/include/boost/leaf/all.hpp @@ -5,6 +5,7 @@ //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #include #include diff --git a/include/boost/leaf/current_exception_diagnostic_output.hpp b/include/boost/leaf/current_exception_diagnostic_output.hpp new file mode 100644 index 0000000..e0b6f67 --- /dev/null +++ b/include/boost/leaf/current_exception_diagnostic_output.hpp @@ -0,0 +1,54 @@ +//Copyright (c) 2018 Emil Dotchevski +//Copyright (c) 2018 Second Spectrum, Inc. + +//Distributed under the Boost Software License, Version 1.0. (See accompanying +//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef UUID_17228D24F83C11E8AAC53F8F652D5A5F +#define UUID_17228D24F83C11E8AAC53F8F652D5A5F + +#include + +namespace boost { namespace leaf { + + template + void current_exception_diagnostic_output( std::ostream & os, expect const & exp ) + { + os << "Current Exception Diagnostic Information:" << std::endl; + + try + { + throw; + } + catch( std::exception const & ex ) + { + os << + "Exception dynamic type: " << typeid(ex).name() << std::endl << + "std::exception::what(): " << ex.what() << std::endl; + } + catch( ... ) + { + os << "Unknown exception type (not a std::exception)" << std::endl; + } + + try + { + throw; + } + catch( leaf_detail::captured_exception const & e ) + { + diagnostic_output_(os,e); + } + catch( error const & e ) + { + diagnostic_output(os,exp,e); + } + catch( ... ) + { + diagnostic_output(os,exp); + } + } + +} } + +#endif diff --git a/include/boost/leaf/error_capture.hpp b/include/boost/leaf/error_capture.hpp index 8ee088c..b9c2af1 100644 --- a/include/boost/leaf/error_capture.hpp +++ b/include/boost/leaf/error_capture.hpp @@ -138,8 +138,8 @@ namespace boost { namespace leaf { return 0; } - virtual void diagnostic_output( std::ostream & ) const = 0; - virtual void unload( error const & ) noexcept = 0; + virtual void diagnostic_output_( std::ostream & ) const = 0; + virtual void unload_( error const & ) noexcept = 0; }; //////////////////////////////////////// @@ -163,12 +163,12 @@ namespace boost { namespace leaf { return tuple_for_each_capture...>>::dynamic_bind(s_,type_id); } - void diagnostic_output( std::ostream & os ) const + void diagnostic_output_( std::ostream & os ) const { leaf_detail::tuple_for_each_capture::print(os,s_); } - void unload( error const & e ) noexcept + void unload_( error const & e ) noexcept { leaf_detail::tuple_for_each_capture::unload(e,std::move(s_)); } @@ -269,7 +269,7 @@ namespace boost { namespace leaf { { if( ds_ ) { - ds_->unload(e_); + ds_->unload_(e_); free(); } return e_; @@ -304,7 +304,7 @@ namespace boost { namespace leaf { inline void diagnostic_output( std::ostream & os, error_capture const & e ) { if( e ) - e.ds_->diagnostic_output(os); + e.ds_->diagnostic_output_(os); } } } diff --git a/include/boost/leaf/exception_capture.hpp b/include/boost/leaf/exception_capture.hpp index c9b6a51..987e69f 100644 --- a/include/boost/leaf/exception_capture.hpp +++ b/include/boost/leaf/exception_capture.hpp @@ -44,7 +44,7 @@ namespace boost { namespace leaf { std::rethrow_exception(ex_); } - friend void diagnostic_output( std::ostream & os, captured_exception const & ce ) + friend void diagnostic_output_( std::ostream & os, captured_exception const & ce ) { diagnostic_output(os,static_cast(ce)); } @@ -103,45 +103,6 @@ namespace boost { namespace leaf { } } - //////////////////////////////////////// - - template - void current_exception_diagnostic_output( std::ostream & os, expect const & exp ) - { - os << "Current Exception Diagnostic Information:" << std::endl; - try - { - throw; - } - catch( std::exception const & ex ) - { - os << - "Exception dynamic type: " << typeid(ex).name() << std::endl << - "std::exception::what(): " << ex.what() << std::endl; - } - catch( ... ) - { - os << "Unknown exception type (not a std::exception)" << std::endl; - } - - try - { - throw; - } - catch( leaf_detail::captured_exception const & e ) - { - diagnostic_output(os,e); - } - catch( error const & e ) - { - diagnostic_output(os,exp,e); - } - catch( ... ) - { - diagnostic_output(os,exp); - } - } - } } #endif diff --git a/test/diagnostic_output_test.cpp b/test/diagnostic_output_test.cpp index 448d8b6..eaf2232 100644 --- a/test/diagnostic_output_test.cpp +++ b/test/diagnostic_output_test.cpp @@ -4,9 +4,9 @@ //Distributed under the Boost Software License, Version 1.0. (See accompanying //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#include -#include +#include #include +#include #include #include