Skip to content

Exceptions

Sebastian Schmieschek edited this page Aug 12, 2015 · 2 revisions

Exceptions in HemeLB

We have taken the decision to allow C++ exceptions in HemeLB, but only for truly exceptional errors, typically ones that should cause the simulation to terminate. Non-fatal exceptions are allowed only during initialisation of the simulation and only in response to unpredictable conditions.

This decision allows the use of the RAII pattern and avoid the separation of construction and initialisation of objects (i.e. Foo f = Foo(); then f.Init();)

All exceptions thrown by HemeLB code should either be or inherit from hemelb::Exception. This implements an std::ostream style interface for operator<< allowing formatted output usage like:

throw Exception() << "Simulation unstable at t = " << currentTime;
Clone this wiki locally