ATLAS Offline Software
Loading...
Searching...
No Matches
CheckExc.h File Reference
#include <ostream>
#include <stdexcept>
Include dependency graph for CheckExc.h:

Go to the source code of this file.

Macros

#define CHECK_EXC(ARG)
 Checks the result of a call, and if it is false, or StatusCode::FAILURE, raise an exception.

Macro Definition Documentation

◆ CHECK_EXC

#define CHECK_EXC ( ARG)
Value:
do { \
const bool result = static_cast<bool>(ARG); \
if (!result) { \
std::ostringstream os; \
os << "Failed to execute: \"" << #ARG << "\""; \
throw std::runtime_error(os.str()); \
} \
} while (false)

Checks the result of a call, and if it is false, or StatusCode::FAILURE, raise an exception.

Use this for cases where you don't have code to recover from a failure, or where you don't expect the command to fail under normal circumstances.

Definition at line 16 of file CheckExc.h.

16#define CHECK_EXC(ARG) \
17 do { \
18 const bool result = static_cast<bool>(ARG); \
19 if (!result) { \
20 std::ostringstream os; \
21 os << "Failed to execute: \"" << #ARG << "\""; \
22 throw std::runtime_error(os.str()); \
23 } \
24 } while (false)