10 #ifndef CMR_ERRUTIL_HPP 11 #define CMR_ERRUTIL_HPP 25 #define CMR_CATCH_PRINT_THROW( msg, new_ex ) catch(const std::exception &e) \ 26 { std::cerr << e.what() << " " << msg << ".\n"; throw new_ex; } 37 template <
typename act_type>
70 template <
typename act_type>
88 std::runtime_error(func_name +
" failed with rval " +
89 std::to_string(rval)) {}
retcode_error(const int rval, const std::string &func_name)
Construct a retcode_error with retcode and function name.
Definition: err_util.hpp:87
ScopeGuard(act_type action)
Construct a ScopeGuard to performs action upon going out of scope.
Definition: err_util.hpp:42
ScopeGuard< act_type > make_guard(act_type f)
Type deduction function for ScopeGuard, also from Andrei Alexandrescu.
Definition: err_util.hpp:71
Code from Andrei Alexandrescu's ScopeGuard11 slides.
Definition: err_util.hpp:38
bool active
True iff final_action should be performed on destruction.
Definition: err_util.hpp:63
ScopeGuard()=delete
No default constructor.
Structure for converting retcodes to exceptions.
Definition: err_util.hpp:81
ScopeGuard & operator=(const ScopeGuard &)=delete
No copy assign.
~ScopeGuard()
Perform the final_action.
Definition: err_util.hpp:46
ScopeGuard(ScopeGuard &&rhs)
Move constructor. Moved from ScopeGuard rhs is dismissed.
Definition: err_util.hpp:57
void dismiss()
Indicate that final_action should not happen.
Definition: err_util.hpp:49
The namespace for this project.
Definition: abc_nodesel.hpp:20
act_type final_action
A function to be called on destruction.
Definition: err_util.hpp:62