*/
void suppress_stacktrace_in_exceptions ();
+ /**
+ * Calling this function switches off
+ * the use of std::abort() when an
+ * exception is created using the
+ * Assert() macro. Generally, you
+ * want to abort the execution of a
+ * program when Assert() is called,
+ * but it needs to be switched off
+ * if you want to log all exceptions
+ * created, or if you want to test
+ * if an assertion is working
+ * correctly. This is done for example
+ * in regression tests.
+ * Please note that some fatal
+ * errors will still call abort(), e.g.
+ * when an exception is caught
+ * during exception handling
+ */
+ void disable_abort_on_exception ();
+
/**
* The functions in this namespace are in connection with the Assert
* and AssertThrow mechanism but are solely for internal purposes and
void suppress_stacktrace_in_exceptions ()
{
show_stacktrace = false;
- }
+ }
+
+
+ bool abort_on_exception = true;
+
+ void disable_abort_on_exception ()
+ {
+ abort_on_exception = false;
+ }
}
}
-
void ExceptionBase::print_exc_data (std::ostream &out) const
{
out << "An error occurred in line <" << line
}
-
void ExceptionBase::print_info (std::ostream &out) const
{
out << "(none)" << std::endl;
}
-
const char * ExceptionBase::what () const throw ()
{
// if we say that this function
<< "*** Message is " << std::endl
<< exc.what () << std::endl
<< "*** Aborting! ***" << std::endl;
+
std::abort ();
- return 0;
}
catch (...)
{
std::cerr << "*** Exception encountered in exception handling routines ***"
<< std::endl
<< "*** Aborting! ***" << std::endl;
+
std::abort ();
- return 0;
}
}
* zero.
*/
unsigned int n_treated_exceptions;
+ ExceptionBase *last_exception;
void issue_error_assert (const char *file,
const char *exc_name,
ExceptionBase &e)
{
- // fill the fields of the
+ // fill the fields of the
// exception object
- e.set_fields (file, line, function, cond, exc_name);
+ e.set_fields (file, line, function, cond, exc_name);
// if no other exception has
// been displayed before, show
// this one
if (n_treated_exceptions == 0)
{
- std::cerr << "--------------------------------------------------------"
+ std::cerr << "--------------------------------------------------------"
<< std::endl;
// print out general data
e.print_exc_data (std::cerr);
// increase number of treated
// exceptions by one
n_treated_exceptions++;
+ last_exception = &e;
// abort the program now since
std::cerr << "******** Program is not aborted since another exception is active! ********"
<< std::endl;
}
- else
- std::abort ();
+ else if(deal_II_exceptions::abort_on_exception == true)
+ std::abort ();
}
void abort ()
{
- std::abort ();
+ if (deal_II_exceptions::abort_on_exception == true)
+ std::abort ();
}
}
{
struct preload_terminate_dummy
{
- preload_terminate_dummy()
- { std::set_terminate (__gnu_cxx::__verbose_terminate_handler); }
+ preload_terminate_dummy()
+ { std::set_terminate(__gnu_cxx::__verbose_terminate_handler); }
};
static preload_terminate_dummy dummy;