*/
namespace deal_II_exceptions
{
- /**
- * Setting this variable to false will disable deal.II's exception mechanism
- * to abort the problem. The Assert() macro will throw the exception instead
- * and the AssertNothrow() macro will just print the error message. This
- * variable should not be changed directly. Use disable_abort_on_exception()
- * instead.
- */
- extern bool allow_abort_on_exception;
+ namespace internals
+ {
+ /**
+ * Setting this variable to false will disable deal.II's exception mechanism
+ * to abort the problem. The Assert() macro will throw the exception instead
+ * and the AssertNothrow() macro will just print the error message. This
+ * variable should not be changed directly. Use disable_abort_on_exception()
+ * instead.
+ */
+ extern bool allow_abort_on_exception;
+ } // namespace internals
/**
* Set a string that is printed upon output of the message indicating a
* error message provided by @p exc and calling <tt>std::abort()</tt>.
*/
[[noreturn]] void
- internal_abort(const ExceptionBase &exc) noexcept;
+ abort(const ExceptionBase &exc) noexcept;
/**
* An enum describing how to treat an exception in issue_error_noreturn.
* deal_II_exceptions::disable_abort_on_exception has been called: in
* that case the program will throw an exception.
*/
- try_abort_on_exception,
+ abort_or_throw_on_exception,
/**
* Throw the exception normally.
*/
/**
* This routine does the main work for the exception generation mechanism
* used in the <tt>Assert</tt> and <tt>AssertThrow</tt> macros: as the
- * name implies, this function either ends throwing an exception (if
+ * name implies, this function either ends by throwing an exception (if
* @p handling is throw_on_exception, or @p handling is try_abort_exception
* and deal_II_exceptions::disable_abort_on_exception is false) or with a
* call to <tt>abort</tt> (if @p handling is try_abort_exception and
switch (handling)
{
- case try_abort_on_exception:
+ case abort_or_throw_on_exception:
{
- if (dealii::deal_II_exceptions::allow_abort_on_exception)
- internals::internal_abort(e);
+ if (dealii::deal_II_exceptions::internals::
+ allow_abort_on_exception)
+ internals::abort(e);
else
{
// We are not allowed to abort, so just throw the error:
*/
#ifdef DEBUG
# ifdef DEAL_II_HAVE_BUILTIN_EXPECT
-# define Assert(cond, exc) \
- { \
- if (__builtin_expect(!(cond), false)) \
- ::dealii::deal_II_exceptions::internals::issue_error_noreturn( \
- ::dealii::deal_II_exceptions::internals::try_abort_on_exception, \
- __FILE__, \
- __LINE__, \
- __PRETTY_FUNCTION__, \
- #cond, \
- #exc, \
- exc); \
+# define Assert(cond, exc) \
+ { \
+ if (__builtin_expect(!(cond), false)) \
+ ::dealii::deal_II_exceptions::internals::issue_error_noreturn( \
+ ::dealii::deal_II_exceptions::internals:: \
+ abort_or_throw_on_exception, \
+ __FILE__, \
+ __LINE__, \
+ __PRETTY_FUNCTION__, \
+ #cond, \
+ #exc, \
+ exc); \
}
# else /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
-# define Assert(cond, exc) \
- { \
- if (!(cond)) \
- ::dealii::deal_II_exceptions::internals::issue_error_noreturn( \
- ::dealii::deal_II_exceptions::internals::try_abort_on_exception, \
- __FILE__, \
- __LINE__, \
- __PRETTY_FUNCTION__, \
- #cond, \
- #exc, \
- exc); \
+# define Assert(cond, exc) \
+ { \
+ if (!(cond)) \
+ ::dealii::deal_II_exceptions::internals::issue_error_noreturn( \
+ ::dealii::deal_II_exceptions::internals:: \
+ abort_or_throw_on_exception, \
+ __FILE__, \
+ __LINE__, \
+ __PRETTY_FUNCTION__, \
+ #cond, \
+ #exc, \
+ exc); \
}
# endif /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
#else
namespace deal_II_exceptions
{
- std::string additional_assert_output;
+ namespace internals
+ {
+ std::string additional_assert_output;
+
+ bool show_stacktrace = true;
+
+ bool allow_abort_on_exception = true;
+ } // namespace internals
void
set_additional_assert_output(const char *const p)
{
- additional_assert_output = p;
+ internals::additional_assert_output = p;
}
- bool show_stacktrace = true;
-
void
suppress_stacktrace_in_exceptions()
{
- show_stacktrace = false;
+ internals::show_stacktrace = false;
}
- bool allow_abort_on_exception = true;
-
void
disable_abort_on_exception()
{
- allow_abort_on_exception = false;
+ internals::allow_abort_on_exception = false;
}
-
} // namespace deal_II_exceptions
if (n_stacktrace_frames == 0)
return;
- if (deal_II_exceptions::show_stacktrace == false)
+ if (deal_II_exceptions::internals::show_stacktrace == false)
return;
// if there is a stackframe stored, print it
print_info(converter);
print_stack_trace(converter);
- if (!deal_II_exceptions::additional_assert_output.empty())
+ if (!deal_II_exceptions::internals::additional_assert_output.empty())
{
converter
<< "--------------------------------------------------------"
<< std::endl
- << deal_II_exceptions::additional_assert_output << std::endl;
+ << deal_II_exceptions::internals::additional_assert_output
+ << std::endl;
}
converter << "--------------------------------------------------------"
namespace internals
{
[[noreturn]] void
- internal_abort(const ExceptionBase &exc) noexcept
+ abort(const ExceptionBase &exc) noexcept
{
// first print the error
std::cerr << exc.what() << std::endl;
void
do_issue_error_nothrow(const ExceptionBase &exc) noexcept
{
- if (dealii::deal_II_exceptions::allow_abort_on_exception)
- internal_abort(exc);
+ if (deal_II_exceptions::internals::allow_abort_on_exception)
+ abort(exc);
else
{
// We are not allowed to throw, and not allowed to abort.
DEAL_II_NAMESPACE_OPEN
namespace deal_II_exceptions
{
- extern bool show_stacktrace;
+ namespace internals
+ {
+ extern bool show_stacktrace;
+ }
} // namespace deal_II_exceptions
DEAL_II_NAMESPACE_CLOSE
std::cerr << "Detailed description: " << comment << std::endl;
// Reenable abort and stacktraces:
- deal_II_exceptions::allow_abort_on_exception = true;
- deal_II_exceptions::show_stacktrace = true;
+ deal_II_exceptions::internals::allow_abort_on_exception = true;
+ deal_II_exceptions::internals::show_stacktrace = true;
// And abort with a deal.II exception:
Assert(false, ExcMessage("TBB Exception, see above"));