OGR
Functions
cpl_error.h File Reference
#include "cpl_port.h"

Go to the source code of this file.

Functions

void CPLError (CPLErr eErrClass, int err_no, const char *fmt,...)
 
void CPLEmergencyError (const char *)
 
void CPLErrorReset (void)
 
int CPLGetLastErrorNo (void)
 
CPLErr CPLGetLastErrorType (void)
 
const char * CPLGetLastErrorMsg (void)
 
void * CPLGetErrorHandlerUserData (void)
 
CPLErrorHandler CPLSetErrorHandler (CPLErrorHandler)
 
CPLErrorHandler CPLSetErrorHandlerEx (CPLErrorHandler, void *)
 
void CPLPushErrorHandler (CPLErrorHandler)
 
void CPLPushErrorHandlerEx (CPLErrorHandler, void *)
 
void CPLPopErrorHandler (void)
 
void CPLDebug (const char *, const char *,...)
 
void _CPLAssert (const char *, const char *, int)
 

Detailed Description

CPL error handling services.

Function Documentation

void _CPLAssert ( const char *  pszExpression,
const char *  pszFile,
int  iLine 
)

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.

References CPLError().

void CPLDebug ( const char *  pszCategory,
const char *  pszFormat,
  ... 
)

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.

Parameters
pszCategoryname of the debugging message category.
pszFormatprintf() style format string for message to display. Remaining arguments are assumed to be for format.

References CPLGetConfigOption().

Referenced by OGRSFDriverRegistrar::AutoLoadDrivers(), CPLDumpSharedList(), CPLFGets(), CPLHTTPFetch(), CPLQuadTreeGetAdvisedMaxDepth(), CPLSetErrorHandlerEx(), CPLUnescapeString(), OGRGeometryFactory::createFromWkb(), OGRSpatialReference::Dereference(), OGRGeometry::Distance(), CPLODBCSession::EstablishSession(), OGRSpatialReference::exportToPanorama(), OGRSpatialReference::exportToPCI(), OGRSpatialReference::exportToUSGS(), OGRLineString::exportToWkt(), OGRPolygon::exportToWkt(), OGRMultiPolygon::exportToWkt(), OGRMultiPoint::exportToWkt(), OGRMultiLineString::exportToWkt(), OGR_SRSNode::FixupOrdering(), OGRSpatialReference::GetAxis(), CPLODBCStatement::GetTables(), GOA2GetAccessToken(), GOA2GetRefreshToken(), OGRSpatialReference::importFromESRI(), OGRSpatialReference::importFromOzi(), OGRSpatialReference::importFromPanorama(), OGRSpatialReference::importFromPCI(), OGRSpatialReference::importFromProj4(), OGRSpatialReference::importFromUSGS(), CPLODBCDriverInstaller::InstallDriver(), OGRSpatialReference::morphFromESRI(), OGRSpatialReference::morphToESRI(), OGR_Dr_CreateDataSource(), OGRBuildPolygonFromEdges(), OGRSFDriverRegistrar::Open(), OGRGeometryFactory::organizePolygons(), OGRSpatialReference::SetFromUserInput(), OGRSpatialReference::SetGeocCS(), OGRSpatialReference::SetLocalCS(), OGRSpatialReference::SetProjCS(), OGRPolygon::transform(), OGRGeometryCollection::transform(), OGRSpatialReference::Validate(), and VSIGetMemFileBuffer().

void CPLEmergencyError ( const char *  pszMessage)

Fatal error when things are bad.

This function should be called in an emergency situation where it is unlikely that a regular error report would work. This would include in the case of heap exhaustion for even small allocations, or any failure in the process of reporting an error (such as TLS allocations).

This function should never return. After the error message has been reported as best possible, the application will abort() similarly to how CPLError() aborts on CE_Fatal class errors.

Parameters
pszMessagethe error message to report.

Referenced by CPLMalloc(), and CPLRealloc().

void CPLError ( CPLErr  eErrClass,
int  err_no,
const char *  fmt,
  ... 
)

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