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
152void CPL_DLL CPLCleanupErrorMutex(
void );
170#ifdef WITHOUT_CPLDEBUG
181# define CPLAssert(expr) ((expr) ? (void)(0) : _CPLAssert(#expr,__FILE__,__LINE__))
183# define CPLAssertAlwaysEval(expr) CPLAssert(expr)
186# define CPLAssert(expr)
189# define CPLAssertAlwaysEval(expr) CPL_IGNORE_RET_VAL(expr)
192# define CPLAssertAlwaysEval(expr) (void)(expr)
203# define VALIDATE_POINTER_ERR CE_Fatal
205# define VALIDATE_POINTER_ERR CE_Failure
209#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS) && !defined(DOXYGEN_SKIP)
216class CPLErrorHandlerPusher
229 ~CPLErrorHandlerPusher()
235class CPLErrorStateBackuper
239 std::string m_osLastErrorMsg;
242 CPLErrorStateBackuper() :
248 ~CPLErrorStateBackuper()
251 m_osLastErrorMsg.c_str());
257#ifdef GDAL_COMPILATION
259bool CPLIsDefaultErrorHandlerAndCatchDebug();
267#define VALIDATE_POINTER0(ptr, func) \
268 do { if( CPL_NULLPTR == ptr ) \
270 CPLErr const ret = VALIDATE_POINTER_ERR; \
271 CPLError( ret, CPLE_ObjectNull, \
272 "Pointer \'%s\' is NULL in \'%s\'.\n", #ptr, (func)); \
276#define VALIDATE_POINTER1(ptr, func, rc) \
277 do { if( CPL_NULLPTR == ptr ) \
279 CPLErr const ret = VALIDATE_POINTER_ERR; \
280 CPLError( ret, CPLE_ObjectNull, \
281 "Pointer \'%s\' is NULL in \'%s\'.\n", #ptr, (func)); \
282 return (rc); }} while(0)
#define CPLE_IllegalArg
Illegal argument.
Definition: cpl_error.h:107
void CPLErrorSetState(CPLErr eErrClass, CPLErrorNum err_no, const char *pszMsg)
Restore an error state, without emitting an error.
Definition: cpl_error.cpp:764
GUInt32 CPLGetErrorCounter(void)
Get the error counter.
Definition: cpl_error.cpp:889
#define CPLE_AWSObjectNotFound
AWSObjectNotFound.
Definition: cpl_error.h:127
#define CPLE_AssertionFailed
Assertion failed.
Definition: cpl_error.h:111
void CPLPushErrorHandlerEx(CPLErrorHandler, void *)
Push a new CPLError handler with user data on the error context.
Definition: cpl_error.cpp:1208
#define CPLE_AWSSignatureDoesNotMatch
AWSSignatureDoesNotMatch.
Definition: cpl_error.h:133
#define CPLE_None
No error.
Definition: cpl_error.h:97
void CPLErrorReset(void)
Erase any traces of previous errors.
Definition: cpl_error.cpp:729
void _CPLAssert(const char *, const char *, int) CPL_NO_RETURN
Report failure of a logical assertion.
Definition: cpl_error.cpp:1315
void CPLLoggingErrorHandler(CPLErr, CPLErrorNum, const char *)
Error handler that logs into the file defined by the CPL_LOG configuration option,...
Definition: cpl_error.cpp:982
#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
CPLErrorNum CPLGetLastErrorNo(void)
Fetch the last error number.
Definition: cpl_error.cpp:818
#define CPLE_AppDefined
Application defined error.
Definition: cpl_error.h:99
#define CPLE_OpenFailed
Open failed.
Definition: cpl_error.h:105
const char * CPLGetLastErrorMsg(void)
Get the last error message.
Definition: cpl_error.cpp:866
CPLErrorHandler CPLSetErrorHandler(CPLErrorHandler)
Install custom error handler.
Definition: cpl_error.cpp:1164
void CPLEmergencyError(const char *) CPL_NO_RETURN
Fatal error when things are bad.
Definition: cpl_error.cpp:489
#define CPLE_AWSAccessDenied
AWSAccessDenied.
Definition: cpl_error.h:129
#define CPLE_ObjectNull
NULL object.
Definition: cpl_error.h:117
void CPLDefaultErrorHandler(CPLErr, CPLErrorNum, const char *)
Default error handler.
Definition: cpl_error.cpp:903
CPLErr CPLGetLastErrorType(void)
Fetch the last error type.
Definition: cpl_error.cpp:842
int CPLErrorNum
Error number.
Definition: cpl_error.h:94
void * CPLGetErrorHandlerUserData(void)
Fetch the user data for the error context.
Definition: cpl_error.cpp:186
void(* CPLErrorHandler)(CPLErr, CPLErrorNum, const char *)
Callback for a custom error handler.
Definition: cpl_error.h:156
void CPLTurnFailureIntoWarning(int bOn)
Whether failures should be turned into warnings.
Definition: cpl_error.cpp:1058
#define CPLE_HttpResponse
HTTP response.
Definition: cpl_error.h:123
#define CPLE_AWSBucketNotFound
AWSBucketNotFound.
Definition: cpl_error.h:125
void CPLPopErrorHandler(void)
Pop error handler off stack.
Definition: cpl_error.cpp:1242
void CPLDebug(const char *, const char *,...)
Display a debugging message.
Definition: cpl_error.cpp:602
void CPLPushErrorHandler(CPLErrorHandler)
Push a new CPLError handler.
Definition: cpl_error.cpp:1185
#define CPLE_NoWriteAccess
No write access.
Definition: cpl_error.h:113
#define CPLE_UserInterrupt
User interrupted.
Definition: cpl_error.h:115
void CPLErrorV(CPLErr, CPLErrorNum, const char *, va_list)
Same as CPLError() but with a va_list.
Definition: cpl_error.cpp:324
void CPLQuietErrorHandler(CPLErr, CPLErrorNum, const char *)
Error handler that does not do anything, except for debug messages.
Definition: cpl_error.cpp:967
#define CPLE_OutOfMemory
Out of memory error.
Definition: cpl_error.h:101
CPLErrorHandler CPLSetErrorHandlerEx(CPLErrorHandler, void *)
Install custom error handle with user's data.
Definition: cpl_error.cpp:1090
void CPLSetCurrentErrorHandlerCatchDebug(int bCatchDebug)
Set if the current error handler should intercept debug messages, or if they should be processed by t...
Definition: cpl_error.cpp:1281
void CPLError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt,...)
Report an error.
Definition: cpl_error.cpp:308
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:956
#define CPL_C_END
Macro to end a block of C symbols.
Definition: cpl_port.h:339
#define CPL_C_START
Macro to start a block of C symbols.
Definition: cpl_port.h:337
#define CPL_FORMAT_STRING(arg)
Macro into which to wrap the format argument of a printf-like function.
Definition: cpl_port.h:929
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:914