iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Exception base classes and helper functions

Classes

class  nrt::exception::Exception
 Exception base class for NRT. This is essentially the same as std::exception but in the nrt namespace. More...
 
class  nrt::exception::SerializableException
 Base class for a serializable exception. Anything that derives from this must implement serialize() More...
 

Namespaces

 nrt::exception
 Reserved namespace for NRT-related exceptions.
 

Functions

void nrt::warnAndRethrowException ()
 Convenience function to catch an exception, issue some NRT_WARNING (depending on type), and rethrow it. More...
 
void nrt::warnAndIgnoreException ()
 Convenience function to catch an exception, issue some NRT_WARNING (depending on type), and ignore it. More...
 

Function Documentation

void nrt::warnAndRethrowException ( )

Convenience function to catch an exception, issue some NRT_WARNING (depending on type), and rethrow it.

User code that is not going to swallow exceptions can use this function as follows, to log some trace of the exception that was thrown:

try { do_something_risky(); } catch (...) { nrt::warnAndRethrowException(); }
Note
This function throws! So obviously it only makes sense to use it inside a catch block.
Examples:
tests/test-Module.C, tests/test-split-messages.C, and tests/test-TransformManager.C.

Referenced by main().

void nrt::warnAndIgnoreException ( )

Convenience function to catch an exception, issue some NRT_WARNING (depending on type), and ignore it.

User code can use this function as follows, to log some trace of the exception that was thrown, and then swallow (ignore) the exception. Use this sparingly, swallowing exceptions often defeats the whole logic of using exceptions in the first place. Example use:

try { do_something_risky_and_we_dont_care_if_it_fails(); } catch (...) { nrt::warnAndIgnoreException(); }