1 /********************************************************************** 2 * 3 * Name: cpl_error.h 4 * Project: CPL - Common Portability Library 5 * Purpose: CPL Error handling 6 * Author: Daniel Morissette, danmo@videotron.ca 7 * 8 ********************************************************************** 9 * Copyright (c) 1998, Daniel Morissette 10 * 11 * Permission is hereby granted, free of charge, to any person obtaining a 12 * copy of this software and associated documentation files (the "Software"), 13 * to deal in the Software without restriction, including without limitation 14 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 15 * and/or sell copies of the Software, and to permit persons to whom the 16 * Software is furnished to do so, subject to the following conditions: 17 * 18 * The above copyright notice and this permission notice shall be included 19 * in all copies or substantial portions of the Software. 20 * 21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 24 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 27 * DEALINGS IN THE SOFTWARE. 28 ********************************************************************** 29 * 30 * $Log: cpl_error.h,v $ 31 * Revision 1.1.1.1 2006/08/21 05:52:20 dsr 32 * Initial import as opencpn, GNU Automake compliant. 33 * 34 * Revision 1.1.1.1 2006/04/19 03:23:28 dsr 35 * Rename/Import to OpenCPN 36 * 37 * Revision 1.16 2001/11/02 22:07:58 warmerda 38 * added logging error handler 39 * 40 * Revision 1.15 2001/01/19 21:16:41 warmerda 41 * expanded tabs 42 * 43 * Revision 1.14 2000/11/30 17:30:10 warmerda 44 * added CPLGetLastErrorType 45 * 46 * Revision 1.13 2000/08/24 18:08:17 warmerda 47 * made default and quiet error handlers public on windows 48 * 49 * Revision 1.12 2000/06/26 21:44:07 warmerda 50 * added CPLE_UserInterrupt for progress terminations 51 * 52 * Revision 1.11 2000/03/31 14:11:55 warmerda 53 * added CPLErrorV 54 * 55 * Revision 1.10 2000/01/10 17:35:45 warmerda 56 * added push down stack of error handlers 57 * 58 * Revision 1.9 1999/07/23 14:27:47 warmerda 59 * CPLSetErrorHandler returns old handler 60 * 61 * Revision 1.8 1999/05/20 14:59:05 warmerda 62 * added CPLDebug() 63 * 64 * Revision 1.7 1999/05/20 02:54:38 warmerda 65 * Added API documentation 66 * 67 * Revision 1.6 1999/02/17 05:40:47 danmo 68 * Fixed CPLAssert() macro to work with EGCS. 69 * 70 * Revision 1.5 1999/01/11 15:34:29 warmerda 71 * added reserved range comment 72 * 73 * Revision 1.4 1998/12/15 19:02:27 warmerda 74 * Avoid use of errno as a variable 75 * 76 * Revision 1.3 1998/12/06 22:20:42 warmerda 77 * Added error code. 78 * 79 * Revision 1.2 1998/12/06 02:52:52 warmerda 80 * Implement assert support 81 * 82 * Revision 1.1 1998/12/03 18:26:02 warmerda 83 * New 84 * 85 **********************************************************************/ 86 87 #ifndef _CPL_ERROR_H_INCLUDED_ 88 #define _CPL_ERROR_H_INCLUDED_ 89 90 #include "cpl_port.h" 91 92 /*===================================================================== 93 Error handling functions (cpl_error.c) 94 =====================================================================*/ 95 96 /** 97 * \file cpl_error.h 98 * 99 * CPL error handling services. 100 */ 101 102 CPL_C_START 103 104 typedef enum 105 { 106 CE_None = 0, 107 CE_Debug = 1, 108 CE_Warning = 2, 109 CE_Failure = 3, 110 CE_Fatal = 4 111 112 } CPLErr; 113 114 void CPL_DLL CPLError(CPLErr eErrClass, int err_no, const char *fmt, ...); 115 void CPL_DLL CPLErrorV(CPLErr, int, const char *, va_list ); 116 void CPL_DLL CPLErrorReset(); 117 int CPL_DLL CPLGetLastErrorNo(); 118 CPLErr CPL_DLL CPLGetLastErrorType(); 119 const char CPL_DLL * CPLGetLastErrorMsg(); 120 121 typedef void (*CPLErrorHandler)(CPLErr, int, const char*); 122 CPLErrorHandler CPL_DLL CPLSetErrorHandler(CPLErrorHandler); 123 void CPL_DLL CPLPushErrorHandler( CPLErrorHandler ); 124 void CPL_DLL CPLPopErrorHandler(); 125 void CPL_DLL CPLDefaultErrorHandler( CPLErr, int, const char * ); 126 void CPL_DLL CPLQuietErrorHandler( CPLErr, int, const char * ); 127 void CPL_DLL CPLLoggingErrorHandler( CPLErr, int, const char * ); 128 129 void CPL_DLL CPLDebug( const char *, const char *, ... ); 130 void CPL_DLL _CPLAssert( const char *, const char *, int ); 131 132 #ifdef DEBUG 133 # define CPLAssert(expr) ((expr) ? (void)(0) : _CPLAssert(#expr,__FILE__,__LINE__)) 134 #else 135 # define CPLAssert(expr) 136 #endif 137 138 CPL_C_END 139 140 /* ==================================================================== */ 141 /* Well known error codes. */ 142 /* ==================================================================== */ 143 144 #define CPLE_None 0 145 #define CPLE_AppDefined 1 146 #define CPLE_OutOfMemory 2 147 #define CPLE_FileIO 3 148 #define CPLE_OpenFailed 4 149 #define CPLE_IllegalArg 5 150 #define CPLE_NotSupported 6 151 #define CPLE_AssertionFailed 7 152 #define CPLE_NoWriteAccess 8 153 #define CPLE_UserInterrupt 9 154 155 /* 100 - 299 reserved for GDAL */ 156 157 #endif /* _CPL_ERROR_H_INCLUDED_ */ 158