19 #ifndef OPM_COMMON_CRITICAL_ERROR_HPP 20 #define OPM_COMMON_CRITICAL_ERROR_HPP 83 std::exception_ptr inner_exception =
nullptr)
85 , m_innerException(inner_exception)
95 const char*
what() const noexcept
override 97 return m_message.c_str();
107 return m_innerException;
111 std::string m_message;
112 std::exception_ptr m_innerException;
117 inline std::string makeCriticalErrorMessageErrorHint(
const std::string& text)
119 return std::string(
"\nError hint: ") + text;
122 inline std::string makeCriticalErrorMessageErrorHint()
124 return std::string(
"");
136 #define OPM_CATCH_AND_RETHROW_AS_CRITICAL_ERROR(...) \ 137 catch (const ::Opm::CriticalError&) \ 141 catch (const std::exception& exp) \ 143 const auto messageForCriticalError = std::string("Error rethrown as CriticalError at [") + __FILE__ + ":" \ 144 + std::to_string(__LINE__) + "].\nOriginal error: " + exp.what() \ 145 + ::Opm::detail::makeCriticalErrorMessageErrorHint(__VA_ARGS__); \ 146 throw ::Opm::CriticalError(messageForCriticalError, std::current_exception()); \ 150 const auto messageForCriticalError = std::string("Error rethrown as CriticalError at [") + __FILE__ + ":" \ 151 + std::to_string(__LINE__) + "]. Unknown original error." \ 152 + ::Opm::detail::makeCriticalErrorMessageErrorHint(__VA_ARGS__); \ 153 throw ::Opm::CriticalError(messageForCriticalError, std::current_exception()); \ 162 #define OPM_TRY_THROW_AS_CRITICAL_ERROR(expr, ...) \ 165 } catch (const ::Opm::CriticalError&) { \ 167 } catch (const std::exception& exp) { \ 168 const auto messageForCriticalError = std::string("Error rethrown as CriticalError at [") + __FILE__ + ":" \ 169 + std::to_string(__LINE__) + "].\nOriginal error: " + exp.what() \ 170 + ::Opm::detail::makeCriticalErrorMessageErrorHint(__VA_ARGS__); \ 171 throw ::Opm::CriticalError(messageForCriticalError, std::current_exception()); \ 173 const auto messageForCriticalError = std::string("Error rethrown as CriticalError at [") + __FILE__ + ":" \ 174 + std::to_string(__LINE__) + "]. Unknown original error." \ 175 + ::Opm::detail::makeCriticalErrorMessageErrorHint(__VA_ARGS__); \ 176 throw ::Opm::CriticalError(messageForCriticalError, std::current_exception()); \ 180 #endif // OPM_COMMON_CRITICAL_ERROR_HPP This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
const char * what() const noexcept override
Returns the error message.
Definition: CriticalError.hpp:95
Definition: CriticalError.hpp:115
A custom exception class that extends std::exception to handle critical errors.
Definition: CriticalError.hpp:73
std::exception_ptr getInnerException() const
Retrieves the inner exception.
Definition: CriticalError.hpp:105
CriticalError(const std::string_view &message, std::exception_ptr inner_exception=nullptr)
Constructs a CriticalError with a specified message and an optional inner exception.
Definition: CriticalError.hpp:82