31#ifndef CPL_ERROR_H_INCLUDED
32#define CPL_ERROR_H_INCLUDED
65#ifdef STRICT_CPLERRORNUM_TYPE
99#define CPLE_AppDefined 1
101#define CPLE_OutOfMemory 2
105#define CPLE_OpenFailed 4
107#define CPLE_IllegalArg 5
109#define CPLE_NotSupported 6
111#define CPLE_AssertionFailed 7
113#define CPLE_NoWriteAccess 8
115#define CPLE_UserInterrupt 9
117#define CPLE_ObjectNull 10
123#define CPLE_HttpResponse 11
125#define CPLE_AWSBucketNotFound 12
127#define CPLE_AWSObjectNotFound 13
129#define CPLE_AWSAccessDenied 14
131#define CPLE_AWSInvalidCredentials 15
133#define CPLE_AWSSignatureDoesNotMatch 16
135#define CPLE_AWSError 17
144void CPL_DLL CPL_STDCALL CPLErrorReset(
void );
145CPLErrorNum CPL_DLL CPL_STDCALL CPLGetLastErrorNo(
void );
146CPLErr CPL_DLL CPL_STDCALL CPLGetLastErrorType(
void );
147const
char CPL_DLL * CPL_STDCALL CPLGetLastErrorMsg(
void );
148GUInt32 CPL_DLL CPL_STDCALL CPLGetErrorCounter(
void );
149void CPL_DLL * CPL_STDCALL CPLGetErrorHandlerUserData(
void);
150void CPL_DLL CPLErrorSetState(
CPLErr eErrClass,
CPLErrorNum err_no, const
char* pszMsg );
152void CPL_DLL CPLCleanupErrorMutex(
void );
158void CPL_DLL CPL_STDCALL CPLLoggingErrorHandler(
CPLErr,
CPLErrorNum, const
char * );
159void CPL_DLL CPL_STDCALL CPLDefaultErrorHandler(
CPLErr,
CPLErrorNum, const
char * );
160void CPL_DLL CPL_STDCALL CPLQuietErrorHandler(
CPLErr,
CPLErrorNum, const
char * );
161void CPLTurnFailureIntoWarning(
int bOn );
166void CPL_DLL CPL_STDCALL CPLPushErrorHandlerEx(
CPLErrorHandler,
void* );
167void CPL_DLL CPL_STDCALL CPLSetCurrentErrorHandlerCatchDebug(
int bCatchDebug );
168void CPL_DLL CPL_STDCALL CPLPopErrorHandler(
void);
170#ifdef WITHOUT_CPLDEBUG
181#define CPLDebugOnly(...) CPLDebug(__VA_ARGS__)
186#define CPLDebugOnly(...)
191#if defined(DEBUG) && !defined(CPPCHECK)
193# define CPLAssert(expr) ((expr) ? (void)(0) : _CPLAssert(#expr,__FILE__,__LINE__))
195# define CPLAssertAlwaysEval(expr) CPLAssert(expr)
198# define CPLAssert(expr)
201# define CPLAssertAlwaysEval(expr) CPL_IGNORE_RET_VAL(expr)
204# define CPLAssertAlwaysEval(expr) (void)(expr)
215# define VALIDATE_POINTER_ERR CE_Fatal
217# define VALIDATE_POINTER_ERR CE_Failure
221#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS) && !defined(DOXYGEN_SKIP)
228class CPLErrorHandlerPusher
233 CPLPushErrorHandler(hHandler);
238 CPLPushErrorHandlerEx(hHandler, user_data);
241 ~CPLErrorHandlerPusher()
243 CPLPopErrorHandler();
247class CPLErrorStateBackuper
251 std::string m_osLastErrorMsg;
254 CPLErrorStateBackuper() :
255 m_nLastErrorNum(CPLGetLastErrorNo()),
256 m_nLastErrorType(CPLGetLastErrorType()),
257 m_osLastErrorMsg(CPLGetLastErrorMsg())
260 ~CPLErrorStateBackuper()
262 CPLErrorSetState(m_nLastErrorType, m_nLastErrorNum,
263 m_osLastErrorMsg.c_str());
269#ifdef GDAL_COMPILATION
271bool CPLIsDefaultErrorHandlerAndCatchDebug();
279#define VALIDATE_POINTER0(ptr, func) \
280 do { if( CPL_NULLPTR == ptr ) \
282 CPLErr const ret = VALIDATE_POINTER_ERR; \
283 CPLError( ret, CPLE_ObjectNull, \
284 "Pointer \'%s\' is NULL in \'%s\'.\n", #ptr, (func)); \
288#define VALIDATE_POINTER1(ptr, func, rc) \
289 do { if( CPL_NULLPTR == ptr ) \
291 CPLErr const ret = VALIDATE_POINTER_ERR; \
292 CPLError( ret, CPLE_ObjectNull, \
293 "Pointer \'%s\' is NULL in \'%s\'.\n", #ptr, (func)); \
294 return (rc); }} while(0)
#define CPLE_IllegalArg
Illegal argument.
Definition cpl_error.h:107
#define CPLE_AWSObjectNotFound
AWSObjectNotFound.
Definition cpl_error.h:127
#define CPLE_AssertionFailed
Assertion failed.
Definition cpl_error.h:111
#define CPLE_AWSSignatureDoesNotMatch
AWSSignatureDoesNotMatch.
Definition cpl_error.h:133
#define CPLE_None
No error.
Definition cpl_error.h:97
#define CPLE_NotSupported
Not supported.
Definition cpl_error.h:109
#define CPLE_AWSInvalidCredentials
AWSInvalidCredentials.
Definition cpl_error.h:131
CPLErr
Error category.
Definition cpl_error.h:53
#define CPLE_FileIO
File I/O error.
Definition cpl_error.h:103
#define CPLE_AppDefined
Application defined error.
Definition cpl_error.h:99
#define CPLE_OpenFailed
Open failed.
Definition cpl_error.h:105
#define CPLE_AWSAccessDenied
AWSAccessDenied.
Definition cpl_error.h:129
#define CPLE_ObjectNull
NULL object.
Definition cpl_error.h:117
int CPLErrorNum
Error number.
Definition cpl_error.h:94
void(* CPLErrorHandler)(CPLErr, CPLErrorNum, const char *)
Callback for a custom error handler.
Definition cpl_error.h:156
void _CPLAssert(const char *, const char *, int)
Report failure of a logical assertion.
Definition cpl_error.cpp:1340
#define CPLE_HttpResponse
HTTP response.
Definition cpl_error.h:123
#define CPLE_AWSBucketNotFound
AWSBucketNotFound.
Definition cpl_error.h:125
void CPLDebug(const char *, const char *,...)
Display a debugging message.
Definition cpl_error.cpp:607
#define CPLE_NoWriteAccess
No write access.
Definition cpl_error.h:113
#define CPLE_UserInterrupt
User interrupted.
Definition cpl_error.h:115
#define CPLE_OutOfMemory
Out of memory error.
Definition cpl_error.h:101
void CPLError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt,...)
Report an error.
Definition cpl_error.cpp:310
Core portability definitions for CPL.
#define CPL_NO_RETURN
Qualifier for a function that does not return at all (terminates the process)
Definition cpl_port.h:911
#define CPL_C_END
Macro to end a block of C symbols.
Definition cpl_port.h:331
#define CPL_C_START
Macro to start a block of C symbols.
Definition cpl_port.h:329
#define CPL_FORMAT_STRING(arg)
Macro into which to wrap the format argument of a printf-like function.
Definition cpl_port.h:884
unsigned int GUInt32
Unsigned int32 type.
Definition cpl_port.h:207
#define CPL_PRINT_FUNC_FORMAT(format_idx, arg_idx)
Tag a function to have printf() formatting.
Definition cpl_port.h:869