MMCore
1.4
|
Core error class. Exceptions thrown by the Core public API are of this type. More...
#include <Error.h>
Public Types | |
typedef int | Code |
Error code type. | |
Public Member Functions | |
CMMError (const std::string &msg, Code code=MMERR_GENERIC) | |
Construct with error message and optionally an error code. More... | |
CMMError (const char *msg, Code code=MMERR_GENERIC) | |
Construct with error message and optionally an error code. More... | |
CMMError (const std::string &msg, Code code, const CMMError &underlyingError) | |
Construct with an error code and underlying (chained/wrapped) error. More... | |
CMMError (const char *msg, Code code, const CMMError &underlyingError) | |
Construct with an error code and underlying (chained/wrapped) error. More... | |
CMMError (const std::string &msg, const CMMError &underlyingError) | |
Construct with an underlying (chained/wrapped) error. More... | |
CMMError (const char *msg, const CMMError &underlyingError) | |
Construct with an underlying (chained/wrapped) error. More... | |
CMMError (const CMMError &other) | |
Copy constructor (perform a deep copy). | |
virtual const char * | what () const throw () |
Implements std::exception interface. | |
virtual std::string | getMsg () const |
Get the error message for this error. | |
virtual std::string | getFullMsg () const |
Get a message containing the messages from all chained errors. | |
virtual Code | getCode () const |
Get the error code for this error. | |
virtual Code | getSpecificCode () const |
Search the chain of underlying errors for the first specific error code. More... | |
virtual const CMMError * | getUnderlyingError () const |
Access the underlying error. More... | |
Core error class. Exceptions thrown by the Core public API are of this type.
Exceptions can be "chained" to express underlying causes of errors.
There are no methods to modify error objects after construction. This is intentional, to keep it easy to determine the source of information. Use chaining if you want to augment error messages with higher-level information.
The main information contained in an instance is the error message and the error code. The message is required and should be concise but should try to provide complete information (including, e.g., parameter values) about the error.
Error codes are optional and are used to distinguish between well known errors by calling code. They are only useful if it is important that the calling code can determine the type of error and take appropriate action.
Note: Although, strictly speaking, exception class constructors are not supposed to throw, we relax this rule and ignore the possibility of a std::bad_alloc. If memory is low enough that error message strings cannot be copied, we're not going to get very far anyway.
|
explicit |
Construct with error message and optionally an error code.
code should not be MMERR_OK (0).
|
explicit |
Construct with error message and optionally an error code.
msg should not be null. code should not be MMERR_OK (0).
Construct with an error code and underlying (chained/wrapped) error.
Use this form of the constructor when adding information and rethrowing the exception.
code should not be MMERR_OK (0).
Construct with an error code and underlying (chained/wrapped) error.
Use this form of the constructor when adding information and rethrowing the exception.
msg should not be null. code should not be MMERR_OK (0).
CMMError::CMMError | ( | const std::string & | msg, |
const CMMError & | underlyingError | ||
) |
Construct with an underlying (chained/wrapped) error.
Use this form of the constructor when adding information and rethrowing the exception.
CMMError::CMMError | ( | const char * | msg, |
const CMMError & | underlyingError | ||
) |
Construct with an underlying (chained/wrapped) error.
Use this form of the constructor when adding information and rethrowing the exception.
msg should not be null.
|
virtual |
Search the chain of underlying errors for the first specific error code.
The chained errors are searched in order and the first code that is not MMERR_GENERIC (1) is returned. If none of the chained errors have a specific code, MMERR_GENERIC is returned.
References getSpecificCode(), and getUnderlyingError().
Referenced by getCode(), and getSpecificCode().
|
virtual |
Access the underlying error.
This is intended for code that wants to perform custom formatting or analysis of the chained errors.
The returned pointer is valid until the instance on which this method was called is destroyed. If there is no underlying error (i.e. if this instance is at the end of the chain), a null pointer is returned.
Referenced by CMMError(), getCode(), getFullMsg(), and getSpecificCode().