DeferredLoggingErrorHelpers.hpp File Reference
#include <opm/common/Exceptions.hpp>
#include <opm/simulators/utils/DeferredLogger.hpp>
#include <opm/simulators/utils/gatherDeferredLogger.hpp>
#include <opm/simulators/utils/ParallelCommunication.hpp>
#include <string>
#include <exception>
#include <stdexcept>
Include dependency graph for DeferredLoggingErrorHelpers.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define OPM_DEFLOG_THROW(Exception, message, deferred_logger)
 
#define OPM_DEFLOG_PROBLEM(Exception, message, deferred_logger)
 
#define OPM_BEGIN_PARALLEL_TRY_CATCH()
 Macro to setup the try of a parallel try-catch. More...
 
#define OPM_PARALLEL_CATCH_CLAUSE(obptc_exc_type, obptc_exc_msg)
 Inserts catch classes for the parallel try-catch. More...
 
#define OPM_END_PARALLEL_TRY_CATCH(prefix, comm)
 Catch exception and throw in a parallel try-catch clause. More...
 
#define OPM_END_PARALLEL_TRY_CATCH_LOG(obptc_logger, obptc_prefix, obptc_output, comm)
 Catch exception, log, and throw in a parallel try-catch clause. More...
 

Functions

void checkForExceptionsAndThrow (Opm::ExceptionType::ExcEnum exc_type, const std::string &message, Opm::Parallel::Communication comm)
 
void logAndCheckForExceptionsAndThrow (Opm::DeferredLogger &deferred_logger, Opm::ExceptionType::ExcEnum exc_type, const std::string &message, const bool terminal_output, Opm::Parallel::Communication comm)
 

Macro Definition Documentation

◆ OPM_BEGIN_PARALLEL_TRY_CATCH

#define OPM_BEGIN_PARALLEL_TRY_CATCH ( )
Value:
std::string obptc_exc_msg; \
auto obptc_exc_type = Opm::ExceptionType::NONE; \
try {
@ NONE
Definition: DeferredLogger.hpp:46

Macro to setup the try of a parallel try-catch.

Use OPM_END_PARALLEL_TRY_CATCH or OPM_END_PARALLEL_TRY_CATCH_LOG fot the catch part.

◆ OPM_DEFLOG_PROBLEM

#define OPM_DEFLOG_PROBLEM (   Exception,
  message,
  deferred_logger 
)
Value:
do { \
std::string oss_ = std::string{"["} + __FILE__ + ":" + \
std::to_string(__LINE__) + "] " + \
message; \
deferred_logger.problem(oss_); \
throw Exception(oss_); \
} while (false)
std::string to_string(const ConvergenceReport::ReservoirFailure::Type t)

◆ OPM_DEFLOG_THROW

#define OPM_DEFLOG_THROW (   Exception,
  message,
  deferred_logger 
)
Value:
do { \
std::string oss_ = std::string{"["} + __FILE__ + ":" + \
std::to_string(__LINE__) + "] " + \
message; \
deferred_logger.error(oss_); \
throw Exception(oss_); \
} while (false)

◆ OPM_END_PARALLEL_TRY_CATCH

#define OPM_END_PARALLEL_TRY_CATCH (   prefix,
  comm 
)
Value:
} \
OPM_PARALLEL_CATCH_CLAUSE(obptc_exc_type, obptc_exc_msg);\
checkForExceptionsAndThrow(obptc_exc_type, \
prefix + obptc_exc_msg, comm);

Catch exception and throw in a parallel try-catch clause.

Assumes that OPM_BEGIN_PARALLEL_TRY_CATCH() was called to initiate the try-catch clause

◆ OPM_END_PARALLEL_TRY_CATCH_LOG

#define OPM_END_PARALLEL_TRY_CATCH_LOG (   obptc_logger,
  obptc_prefix,
  obptc_output,
  comm 
)
Value:
} \
OPM_PARALLEL_CATCH_CLAUSE(obptc_exc_type, obptc_exc_msg); \
logAndCheckForExceptionsAndThrow(obptc_logger, obptc_exc_type, \
obptc_prefix + obptc_exc_msg, obptc_output, comm);

Catch exception, log, and throw in a parallel try-catch clause.

Assumes that OPM_BEGIN_PARALLEL_TRY_CATCH() was called to initiate the try-catch clause

◆ OPM_PARALLEL_CATCH_CLAUSE

#define OPM_PARALLEL_CATCH_CLAUSE (   obptc_exc_type,
  obptc_exc_msg 
)
Value:
catch (const Opm::NumericalProblem& e){ \
obptc_exc_msg = e.what(); \
} catch (const std::runtime_error& e) { \
obptc_exc_msg = e.what(); \
} catch (const std::invalid_argument& e) { \
obptc_exc_msg = e.what(); \
} catch (const std::logic_error& e) { \
obptc_exc_type = Opm::ExceptionType::LOGIC_ERROR; \
obptc_exc_msg = e.what(); \
} catch (const std::exception& e) { \
obptc_exc_type = Opm::ExceptionType::DEFAULT; \
obptc_exc_msg = e.what(); \
} catch (...) { \
obptc_exc_type = Opm::ExceptionType::DEFAULT; \
obptc_exc_msg = "Unknown exception was thrown"; \
}
@ INVALID_ARGUMENT
Definition: DeferredLogger.hpp:48
@ RUNTIME_ERROR
Definition: DeferredLogger.hpp:47
@ LOGIC_ERROR
Definition: DeferredLogger.hpp:49
@ DEFAULT
Definition: DeferredLogger.hpp:50
@ NUMERICAL_ISSUE
Definition: DeferredLogger.hpp:51

Inserts catch classes for the parallel try-catch.

There is a clause that will catch anything

Function Documentation

◆ checkForExceptionsAndThrow()

void checkForExceptionsAndThrow ( Opm::ExceptionType::ExcEnum  exc_type,
const std::string &  message,
Opm::Parallel::Communication  comm 
)
inline

◆ logAndCheckForExceptionsAndThrow()

void logAndCheckForExceptionsAndThrow ( Opm::DeferredLogger deferred_logger,
Opm::ExceptionType::ExcEnum  exc_type,
const std::string &  message,
const bool  terminal_output,
Opm::Parallel::Communication  comm 
)
inline