Boost logo

Boost Users :

From: Bernard (bpwlodarski_at_[hidden])
Date: 2023-10-29 06:53:26


greetings kind regards
may i please inquire how not to obtain "std::exception::what: Unknown
exception" from diagnosic_inforumation() . my meaning is to inquire how to
obtain as per example on boost web page
https://www.boost.org/doc/libs/1_83_0/libs/exception/doc/tutorial_diagnostic_information.html
output : "std::exception::what: example_io error"
id est where did "example_io error" come from as neither boost::exception
nor std:::exception accept constructor string arguments .

 please my code below .
thank you kindly

#include "stl" // #includes all stl #include files
#include "boost\exception\all.hpp"
using namespace std;

struct ceXception : virtual boost::exception, virtual std::exception
{
using this_type = ceXception;
ceXception() {}
auto what() { cerr << __FUNCSIG__ << endl; return string("return from " +
string(__FUNCSIG__)); }
template<typename charType>
friend
std::basic_ostream<charType>& operator<<(std::basic_ostream<charType>&
_ostream, const this_type&) { cerr << "to cerr from " << __FUNCSIG__ <<
endl; _ostream << "to ostream from " << __FUNCSIG__ << endl; return
_ostream; }
};

void foo()
{
try { BOOST_THROW_EXCEPTION(ceXception()); }
catch (ceXception& e)
{
cerr << boost::diagnostic_information(e);
}
}

int main()
{
foo();
return 0;
}



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net