![]() |
The Dune-exceptions are designed to allow a simple derivation of subclasses and to accept a text written in the '<<' syntax.
Example of usage:
#include <dune/common/exceptions.hh> ... class FileNotFoundError : public Dune::IOError {}; ... void fileopen (std::string name) { std::ifstream file; file.open(name.c_str()); if (file == 0) DUNE_THROW(FileNotFoundError, "File " << name << " not found!"); ... file.close(); } ... int main () { try { ... } catch (Dune::IOError &e) { std::cerr << "I/O error: " << e << std::endl; return 1; } catch (Dune::Exception &e) { std::cerr << "Generic Dune error: " << e << std::endl; return 2; } }
See exceptions.hh for detailed info