43#define TRIQS_ERROR(CLASS, NAME) throw CLASS() << "Triqs " << NAME << "\n at " << __FILE__ << " : " << __LINE__ << "\n\n"
46#define TRIQS_RUNTIME_ERROR TRIQS_ERROR(triqs::runtime_error, "runtime error")
49#define TRIQS_KEYBOARD_INTERRUPT TRIQS_ERROR(triqs::keyboard_interrupt, "Ctrl-C")
52#define TRIQS_ASSERT(X) \
53 if (!(X)) TRIQS_RUNTIME_ERROR << AS_STRING(X);
56#define TRIQS_ASSERT2(X, ...) \
57 if (!(X)) TRIQS_RUNTIME_ERROR << AS_STRING(X) << "\n " << __VA_ARGS__;
76 std::stringstream acc;
78 mutable std::string _what;
116 (*this) << std::string(mess);
129 virtual const char *
what() const noexcept {
130 std::stringstream out;
131 out << acc.str() <<
"\nException was thrown on node ";
132 if (mpi::is_initialized()) out << mpi::communicator().rank() <<
"\n";
133 if (getenv(
"TRIQS_SHOW_EXCEPTION_TRACE")) out <<
".. C++ trace is : " <<
trace() <<
"\n";
135 return _what.c_str();
142 virtual const char *
trace() const noexcept {
return _trace.c_str(); }
exception & operator<<(T const &x)
Append a value to the accumulated diagnostic message.
exception(exception const &e) noexcept
Copy constructor copies the accumulated diagnostic message, the captured stack trace and the cached w...
virtual const char * trace() const noexcept
Get the captured stack trace.
exception() noexcept
Default constructor ceates an exception with an empty diagnostic message and an empty stack trace.
virtual ~exception() noexcept
Virtual default destructor.
exception & operator<<(const char *mess)
Append a C string to the accumulated diagnostic message.
virtual const char * what() const noexcept
Build and return the full diagnostic message.
keyboard_interrupt & operator<<(T const &x)
Append a value to the accumulated diagnostic message.
virtual ~keyboard_interrupt() noexcept
Virtual default destructor.
keyboard_interrupt() noexcept
Default constructor creates a keyboard interrupt with an empty diagnostic message.
virtual ~runtime_error() noexcept
Virtual default destructor.
runtime_error() noexcept
Default constructor creates a runtime error with an empty diagnostic message.
runtime_error & operator<<(T const &x)
Append a value to the accumulated diagnostic message.
Common macros used in TRIQS.