exception zusätzliche Infomationen
-
Hallo,
in der Boost-Librarie gibt es eine erweitere exception
Ich habe dazu ein beispiel gefunden
typedef boost::error_info<struct tag_my_info, int> my_info; struct my_error : virtual boost::exception, virtual std::exception { }; try { BOOST_THROW_EXCEPTION(my_error() << my_info(42)); // Uncomment the below (and comment the above) for the program to work //throw my_error() << my_info(42); } catch (my_error& x) { if (int const* mi = boost::get_error_info<my_info>(x)) std::cout << "My info: " << *mi << std::endl; }
In der Zeile "BOOST_THROW_EXCEPTION(my_error() << my_info(42));" wird eine exception ausgelöst.
in "x" stehen jetzt zusätzliche Infos wie: throw_funktion_,throw_file_,throw_line_ (sehr praktisch).
Wie kann ich die Infos in ein std::string kopieren?
-
Vielleicht ist
boost::diagnostic_information(..)
das was du suchst.http://www.boost.org/doc/libs/1_56_0/libs/exception/doc/diagnostic_information.html
BTW: Du bist im falschen Unterforum, hier ist C++/CLI, eine .NET Sprache. Boost ist dagegen für ISO C++.
-
danke,
genau das habe ich gesucht.
" boost::diagnostic_information(..)" liefert einen string zurück mit allen nennenswerten Infomationen
-
Dieser Thread wurde von Moderator/in Jochen Kalmbach aus dem Forum C++/CLI mit .NET in das Forum C++ (alle ISO-Standards) verschoben.
Im Zweifelsfall bitte auch folgende Hinweise beachten:
C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?Dieses Posting wurde automatisch erzeugt.