Gromacs
2022.2
|
#include <testutils/include/testutils/testexceptions.h>
Exception class for reporting errors in tests.
This exception should be used for error conditions that are internal to the test, i.e., do not indicate errors in the tested code.
Public Member Functions | |
TestException (const std::string &reason) | |
Creates a test exception object with the provided detailed reason. More... | |
TestException (const GromacsException &base) | |
Creates a test exception based on another GromacsException object. More... | |
int | errorCode () const override |
Returns the error code corresponding to the exception type. | |
const char * | what () const noexceptoverride |
Returns the reason string for the exception. More... | |
template<class InfoType > | |
const InfoType::value_type * | getInfo () const |
Returns the value associated with given ExceptionInfo. More... | |
template<class Tag , typename T > | |
void | setInfo (const ExceptionInfo< Tag, T > &item) |
Associates extra information with the exception. More... | |
void | prependContext (const std::string &context) |
Adds context information to this exception. More... | |
|
inlineexplicit |
Creates a test exception object with the provided detailed reason.
[in] | reason | Detailed reason for the exception. |
|
inlineexplicit |
Creates a test exception based on another GromacsException object.
[in] | base | Exception to wrap. |
|
inlineinherited |
Returns the value associated with given ExceptionInfo.
InfoType | ExceptionInfo type to get the value for. |
InfoType
, or nullptr
if such info has not been set.Does not throw.
|
inherited |
Adds context information to this exception.
[in] | context | Context string to add. |
std::bad_alloc | if out of memory. |
Typical use is to add additional information higher up in the call stack using this function in a catch block and the rethrow the exception.
|
inlineinherited |
Associates extra information with the exception.
Tag | ExceptionInfo tag type. |
T | ExceptionInfo value type. |
[in] | item | ExceptionInfo to associate. |
std::bad_alloc | if out of memory. |
unspecified | any exception thrown by T copy construction. |
If an item of this type is already associated, it is overwritten.
|
overridenoexceptinherited |
Returns the reason string for the exception.
The return value is the string that was passed to the constructor.