return os;
}
+/// prints the current exception (which presence has been verified by the caller)
+static std::ostream &
+CurrentException_(std::ostream &os)
+{
+ try {
+ throw; // re-throw to recognize the exception type
+ }
+ catch (const TextException &ex) {
+ os << ex; // optimization: this is a lot cheaper than what() below
+ }
+ catch (const std::exception &ex) {
+ os << ex.what();
+ }
+ catch (...) {
+ os << "[unknown exception type]";
+ }
+ return os;
+}
+
std::ostream &
CurrentException(std::ostream &os)
{
if (std::current_exception()) {
- try {
- throw; // re-throw to recognize the exception type
- }
- catch (const TextException &ex) {
- os << ex; // optimization: this is a lot cheaper than what() below
- }
- catch (const std::exception &ex) {
- os << ex.what();
- }
- catch (...) {
- os << "[unknown exception type]";
- }
+ os << CurrentException_;
} else {
os << "[no active exception]";
}
return os;
}
+std::ostream &
+CurrentExceptionExtra(std::ostream &os)
+{
+ if (std::current_exception())
+ os << Debug::Extra << "exception: " << CurrentException_;
+ return os;
+}
+
/// prints active (i.e., thrown but not yet handled) exception
std::ostream &CurrentException(std::ostream &);
+/// If there is an active (i.e., thrown but not yet handled) exception, reports
+/// it on a dedicated DebugExtra line. Otherwise, does nothing.
+std::ostream &CurrentExceptionExtra(std::ostream &);
+
/// efficiently prints TextException
std::ostream &operator <<(std::ostream &, const TextException &);
return;
terminating = true;
- debugs(1, DBG_CRITICAL, "FATAL: Dying from an exception handling failure; exception: " << CurrentException);
+ debugs(1, DBG_CRITICAL, "FATAL: Dying after an undetermined failure" << CurrentExceptionExtra);
Debug::PrepareToDie();
abort();