Dune Core Modules (2.6.0)
Files | |
file | exceptions.hh |
A few common exception classes. | |
Classes | |
class | Dune::Exception |
Base class for Dune-Exceptions. More... | |
struct | Dune::ExceptionHook |
Base class to add a hook to the Dune::Exception. More... | |
class | Dune::IOError |
Default exception class for I/O errors. More... | |
class | Dune::MathError |
Default exception class for mathematical errors. More... | |
class | Dune::RangeError |
Default exception class for range errors. More... | |
class | Dune::NotImplemented |
Default exception for dummy implementations. More... | |
class | Dune::SystemError |
Default exception class for OS errors. More... | |
class | Dune::OutOfMemoryError |
Default exception if memory allocation fails. More... | |
class | Dune::InvalidStateException |
Default exception if a function was called while the object is not in a valid state for that function. More... | |
class | Dune::ParallelError |
Default exception if an error in the parallel communication of the program occurred. More... | |
Macros | |
#define | DUNE_THROW(E, m) |
Functions | |
void | Dune::Exception::message (const std::string &msg) |
store string in internal message buffer | |
const char * | Dune::Exception::what () const noexcept override |
output internal message buffer | |
static void | Dune::Exception::registerHook (ExceptionHook *hook) |
add a functor which is called before a Dune::Exception is emitted (see Dune::ExceptionHook) More... | |
static void | Dune::Exception::clearHook () |
remove all hooks | |
Detailed Description
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)
...
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;
}
}
A few common exception classes.
- See also
- exceptions.hh for detailed info
Macro Definition Documentation
◆ DUNE_THROW
#define DUNE_THROW | ( | E, | |
m | |||
) |
Value:
do { E th__ex; std::ostringstream th__out; \
th__out << THROWSPEC(E) << m; th__ex.message(th__out.str()); throw th__ex; \
} while (0)
Macro to throw an exception
#include <dune/common/exceptions.hh>
- Parameters
-
E exception class derived from Dune::Exception m reason for this exception in ostream-notation
Example:
if (filehandle == 0)
DUNE_THROW automatically adds information about the exception thrown to the text.
- Note
- you can add a hook to be called before a Dune::Exception is emitted, e.g. to add additional information to the exception, or to invoke a debugger during parallel debugging. (see Dune::ExceptionHook)
Function Documentation
◆ registerHook()
|
static |
add a functor which is called before a Dune::Exception is emitted (see Dune::ExceptionHook)
- See also
- Dune::ExceptionHook
|
Legal Statements / Impressum |
Hosted by TU Dresden |
generated with Hugo v0.111.3
(Dec 25, 23:30, 2024)