#include "cpl_port.h"
Go to the source code of this file.
Functions | |
void | CPLError (CPLErr eErrClass, int err_no, const char *fmt,...) |
void | CPLErrorReset () |
int | CPLGetLastErrorNo () |
CPLErr | CPLGetLastErrorType () |
const char * | CPLGetLastErrorMsg () |
CPLErrorHandler | CPLSetErrorHandler (CPLErrorHandler) |
void | CPLPushErrorHandler (CPLErrorHandler) |
void | CPLPopErrorHandler () |
void | CPLDebug (const char *, const char *,...) |
void | _CPLAssert (const char *, const char *, int) |
|
Report failure of a logical assertion. Applications would normally use the CPLAssert() macro which expands into code calling _CPLAssert() only if the condition fails. _CPLAssert() will generate a CE_Fatal error call to CPLError(), indicating the file name, and line number of the failed assertion, as well as containing the assertion itself. There is no reason for application code to call _CPLAssert() directly. |
|
Display a debugging message. The category argument is used in conjunction with the CPL_DEBUG environment variable to establish if the message should be displayed. If the CPL_DEBUG environment variable is not set, no debug messages are emitted (use CPLError(CE_Warning,...) to ensure messages are displayed). If CPL_DEBUG is set, but is an empty string or the word "ON" then all debug messages are shown. Otherwise only messages whose category appears somewhere within the CPL_DEBUG value are displayed (as determinted by strstr()). Categories are usually an identifier for the subsystem producing the error. For instance "GDAL" might be used for the GDAL core, and "TIFF" for messages from the TIFF translator.
|
|
Report an error. This function reports an error in a manner that can be hooked and reported appropriate by different applications. The effect of this function can be altered by applications by installing a custom error handling using CPLSetErrorHandler(). The eErrClass argument can have the value CE_Warning indicating that the message is an informational warning, CE_Failure indicating that the action failed, but that normal recover mechanisms will be used or CE_Fatal meaning that a fatal error has occured, and that CPLError() should not return. The default behaviour of CPLError() is to report errors to stderr, and to abort() after reporting a CE_Fatal error. It is expected that some applications will want to supress error reporting, and will want to install a C++ exception, or longjmp() approach to no local fatal error recovery. Regardless of how application error handlers or the default error handler choose to handle an error, the error number, and message will be stored for recovery with CPLGetLastErrorNo() and CPLGetLastErrorMsg().
|
|
Erase any traces of previous errors. This is normally used to ensure that an error which has been recovered from does not appear to be still in play with high level functions. |
|
Get the last error message. Fetches the last error message posted with CPLError(), that hasn't been cleared by CPLErrorReset(). The returned pointer is to an internal string that should not be altered or freed.
|
|
Fetch the last error number. This is the error number, not the error class.
|
|
Fetch the last error type. This is the error class, not the error number.
|
|
Restore old CPLError handler. Discards the current error handler, and restore the one in use before the last CPLPushErrorHandler() call. |
|
Assign new CPLError handler. The old handler is "pushed down" onto a stack and can be easily restored with CPLPopErrorHandler(). Otherwise this works similarly to CPLSetErrorHandler() which contains more details on how error handlers work.
|
|
Install custom error handler. Allow the library's user to specify his own error handler function. A valid error handler is a C function with the following prototype:
void MyErrorHandler(CPLErr eErrClass, int err_no, const char *msg) Pass NULL to come back to the default behavior. The default behaviour (CPLDefaultErrorHandler()) is to write the message to stderr. The msg will be a partially formatted error message not containing the "ERROR %d:" portion emitted by the default handler. Message formatting is handled by CPLError() before calling the handler. If the error handler function is passed a CE_Fatal class error and returns, then CPLError() will call abort(). Applications wanting to interrupt this fatal behaviour will have to use longjmp(), or a C++ exception to indirectly exit the function. Another standard error handler is CPLQuietErrorHandler() which doesn't make any attempt to report the passed error or warning messages but will process debug messages via CPLDefaultErrorHandler.
|