GDAL

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

cpl_error.h
Go to the documentation of this file.
1 /**********************************************************************
2 * $Id: cpl_error.h 33842 2016-04-01 08:37:32Z rouault $
3 *
4 * Name: cpl_error.h
5 * Project: CPL - Common Portability Library
6 * Purpose: CPL Error handling
7 * Author: Daniel Morissette, danmo@videotron.ca
8 *
9 **********************************************************************
10 * Copyright (c) 1998, Daniel Morissette
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 * DEALINGS IN THE SOFTWARE.
29 ****************************************************************************/
30
31 #ifndef CPL_ERROR_H_INCLUDED
32 #define CPL_ERROR_H_INCLUDED
33
34 #include "cpl_port.h"
35
36 /*=====================================================================
37 Error handling functions (cpl_error.c)
38 =====================================================================*/
39
46 CPL_C_START
47
48 typedef enum
49 {
50 CE_None = 0,
51 CE_Debug = 1,
52 CE_Warning = 2,
53 CE_Failure = 3,
54 CE_Fatal = 4
55 } CPLErr;
56
57 /* ==================================================================== */
58 /* Well known error codes. */
59 /* ==================================================================== */
60
61 #ifdef STRICT_CPLERRORNUM_TYPE
62
63 /* This is not appropriate for the general case, as there are parts */
64 /* of GDAL which use custom error codes, but this can help diagnose confusions */
65 /* between CPLErr and CPLErrorNum */
66 typedef enum
67 {
68 CPLE_None,
69 CPLE_AppDefined,
70 CPLE_OutOfMemory,
71 CPLE_FileIO,
72 CPLE_OpenFailed,
73 CPLE_IllegalArg,
74 CPLE_NotSupported,
75 CPLE_AssertionFailed,
76 CPLE_NoWriteAccess,
77 CPLE_UserInterrupt,
78 CPLE_ObjectNull,
79 CPLE_HttpResponse,
80 CPLE_HttpResponse,
81 CPLE_AWSBucketNotFound,
82 CPLE_AWSObjectNotFound,
83 CPLE_AWSAccessDenied,
84 CPLE_AWSInvalidCredentials,
85 CPLE_AWSSignatureDoesNotMatch,
86 } CPLErrorNum;
87
88 #else
89
90 typedef int CPLErrorNum;
91
92 #define CPLE_None 0
93 #define CPLE_AppDefined 1
94 #define CPLE_OutOfMemory 2
95 #define CPLE_FileIO 3
96 #define CPLE_OpenFailed 4
97 #define CPLE_IllegalArg 5
98 #define CPLE_NotSupported 6
99 #define CPLE_AssertionFailed 7
100 #define CPLE_NoWriteAccess 8
101 #define CPLE_UserInterrupt 9
102 #define CPLE_ObjectNull 10
103
104 /*
105 * Filesystem-specific errors
106 */
107 #define CPLE_HttpResponse 11
108 #define CPLE_AWSBucketNotFound 12
109 #define CPLE_AWSObjectNotFound 13
110 #define CPLE_AWSAccessDenied 14
111 #define CPLE_AWSInvalidCredentials 15
112 #define CPLE_AWSSignatureDoesNotMatch 16
113
114 /* 100 - 299 reserved for GDAL */
115
116 #endif
117
118 void CPL_DLL CPLError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (3, 4);
119 void CPL_DLL CPLErrorV(CPLErr, CPLErrorNum, const char *, va_list );
120 void CPL_DLL CPLEmergencyError( const char * ) CPL_NO_RETURN;
121 void CPL_DLL CPL_STDCALL CPLErrorReset( void );
122 CPLErrorNum CPL_DLL CPL_STDCALL CPLGetLastErrorNo( void );
123 CPLErr CPL_DLL CPL_STDCALL CPLGetLastErrorType( void );
124 const char CPL_DLL * CPL_STDCALL CPLGetLastErrorMsg( void );
125 void CPL_DLL * CPL_STDCALL CPLGetErrorHandlerUserData(void);
126 void CPL_DLL CPLErrorSetState( CPLErr eErrClass, CPLErrorNum err_no, const char* pszMsg );
127 void CPL_DLL CPLCleanupErrorMutex( void );
128
129 typedef void (CPL_STDCALL *CPLErrorHandler)(CPLErr, CPLErrorNum, const char*);
130
131 void CPL_DLL CPL_STDCALL CPLLoggingErrorHandler( CPLErr, CPLErrorNum, const char * );
132 void CPL_DLL CPL_STDCALL CPLDefaultErrorHandler( CPLErr, CPLErrorNum, const char * );
133 void CPL_DLL CPL_STDCALL CPLQuietErrorHandler( CPLErr, CPLErrorNum, const char * );
134 void CPLTurnFailureIntoWarning(int bOn );
135
136 CPLErrorHandler CPL_DLL CPL_STDCALL CPLSetErrorHandler(CPLErrorHandler);
137 CPLErrorHandler CPL_DLL CPL_STDCALL CPLSetErrorHandlerEx(CPLErrorHandler, void*);
138 void CPL_DLL CPL_STDCALL CPLPushErrorHandler( CPLErrorHandler );
139 void CPL_DLL CPL_STDCALL CPLPushErrorHandlerEx( CPLErrorHandler, void* );
140 void CPL_DLL CPL_STDCALL CPLSetCurrentErrorHandlerCatchDebug( int bCatchDebug );
141 void CPL_DLL CPL_STDCALL CPLPopErrorHandler(void);
142
143 void CPL_DLL CPL_STDCALL CPLDebug( const char *, const char *, ... ) CPL_PRINT_FUNC_FORMAT (2, 3);
144 void CPL_DLL CPL_STDCALL _CPLAssert( const char *, const char *, int ) CPL_NO_RETURN;
145
146 #ifdef DEBUG
147 # define CPLAssert(expr) ((expr) ? (void)(0) : _CPLAssert(#expr,__FILE__,__LINE__))
148 #else
149 # define CPLAssert(expr)
150 #endif
151
152 CPL_C_END
153
154 /*
155 * Helper macros used for input parameters validation.
156 */
157 #ifdef DEBUG
158 # define VALIDATE_POINTER_ERR CE_Fatal
159 #else
160 # define VALIDATE_POINTER_ERR CE_Failure
161 #endif
162
163 #define VALIDATE_POINTER0(ptr, func) \
164 do { if( NULL == ptr ) \
165 { \
166 CPLErr const ret = VALIDATE_POINTER_ERR; \
167 CPLError( ret, CPLE_ObjectNull, \
168 "Pointer \'%s\' is NULL in \'%s\'.\n", #ptr, (func)); \
169 return; }} while(0)
170
171 #define VALIDATE_POINTER1(ptr, func, rc) \
172 do { if( NULL == ptr ) \
173 { \
174 CPLErr const ret = VALIDATE_POINTER_ERR; \
175 CPLError( ret, CPLE_ObjectNull, \
176 "Pointer \'%s\' is NULL in \'%s\'.\n", #ptr, (func)); \
177 return (rc); }} while(0)
178
179 #endif /* CPL_ERROR_H_INCLUDED */
CPLPushErrorHandler
void CPLPushErrorHandler(CPLErrorHandler)
Push a new CPLError handler.
Definition: cpl_error.cpp:1062
CPLGetLastErrorType
CPLErr CPLGetLastErrorType(void)
Fetch the last error type.
Definition: cpl_error.cpp:743
cpl_port.h
Core portability definitions for CPL.
_CPLAssert
void _CPLAssert(const char *, const char *, int) CPL_NO_RETURN
Report failure of a logical assertion.
Definition: cpl_error.cpp:1192
CPLSetCurrentErrorHandlerCatchDebug
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:1158
CPLGetLastErrorMsg
const char * CPLGetLastErrorMsg(void)
Get the last error message.
Definition: cpl_error.cpp:767
CPLSetErrorHandlerEx
CPLErrorHandler CPLSetErrorHandlerEx(CPLErrorHandler, void *)
Install custom error handle with user's data.
Definition: cpl_error.cpp:962
CPLPopErrorHandler
void CPLPopErrorHandler(void)
Pop error handler off stack.
Definition: cpl_error.cpp:1120
CPLDebug
void CPLDebug(const char *, const char *,...)
Display a debugging message.
Definition: cpl_error.cpp:473
CPLError
void CPLError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt,...)
Report an error.
Definition: cpl_error.cpp:199
CPLErrorReset
void CPLErrorReset(void)
Erase any traces of previous errors.
Definition: cpl_error.cpp:632
CPLGetErrorHandlerUserData
void * CPLGetErrorHandlerUserData(void)
Fetch the user data for the error context.
Definition: cpl_error.cpp:153
CPLGetLastErrorNo
CPLErrorNum CPLGetLastErrorNo(void)
Fetch the last error number.
Definition: cpl_error.cpp:719
CPLSetErrorHandler
CPLErrorHandler CPLSetErrorHandler(CPLErrorHandler)
Install custom error handler.
Definition: cpl_error.cpp:1041
CPLErrorSetState
void CPLErrorSetState(CPLErr eErrClass, CPLErrorNum err_no, const char *pszMsg)
Restore an error state, without emitting an error.
Definition: cpl_error.cpp:666
CPLEmergencyError
void CPLEmergencyError(const char *) CPL_NO_RETURN
Fatal error when things are bad.
Definition: cpl_error.cpp:385
CPLPushErrorHandlerEx
void CPLPushErrorHandlerEx(CPLErrorHandler, void *)
Push a new CPLError handler with user data on the error context.
Definition: cpl_error.cpp:1086

Generated for GDAL by 1.8.8.