LAL  7.5.0.1-bede9b2
LALError.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2007 Jolien Creighton
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with with program; see the file COPYING. If not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301 USA
18 */
19 
20 /* ---------- SEE LALError.dox for doxygen documentation ---------- */
21 
22 #ifndef _LALERROR_H
23 #define _LALERROR_H
24 
25 #include <lal/LALDebugLevel.h>
26 
27 #include <lal/LALDatatypes.h>
28 
29 #include <lal/XLALError.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #elif 0
34 } /* so that editors will match preceding brace */
35 #endif
36 
37 #ifndef SWIG /* exclude from SWIG interface */
38 
39 extern int (*lalRaiseHook) (int, const char *, ...);
40 extern void (*lalAbortHook) (const char *, ...);
41 
42 /** \addtogroup LALError_h */ /** @{ */
43 
44 int LALPrintError(const char *fmt, ...);
45 
46 int LALRaise(int sig, const char *fmt, ...);
47 
48 void LALAbort(const char *fmt, ...);
49 
50 int LALError(LALStatus * status, const char *statement);
51 
52 int LALWarning(LALStatus * status, const char *warning);
53 
54 int LALInfo(LALStatus * status, const char *info);
55 
56 int LALTrace(LALStatus * status, int exitflg);
57 
58 /** @} */
59 
60 int
61 LALInitStatus(LALStatus * status, const char *function,
62  const char *id, const char *file, const int line);
63 
64 int LALPrepareReturn(LALStatus * status, const char *file, const int line);
65 
66 int
67 LALAttatchStatusPtr(LALStatus * status, const char *file, const int line);
68 
69 int
70 LALDetatchStatusPtr(LALStatus * status, const char *file, const int line);
71 
72 int
73 LALPrepareAbort(LALStatus * status, const INT4 code, const char *mesg,
74  const char *file, const int line);
75 
76 int
78  const char *mesg, const char *statement,
79  const char *file, const int line);
80 
81 int
82 LALCheckStatusPtr(LALStatus * status, const char *statement,
83  const char *file, const int line);
84 
85 #ifdef LAL_STATUS_MACROS_DISABLED
86 
88 
90 
91 #endif
92 
93 #ifndef LAL_STATUS_MACROS_DISABLED
94 
95 #define LALError( statusptr, statement ) \
96  ( lalDebugLevel & LALERROR ? \
97  LALPrintError( "Error[%d] %d: function %s, file %s, line %d, %s\n" \
98  " %s %s\n", (statusptr)->level, (statusptr)->statusCode, \
99  (statusptr)->function, (statusptr)->file, (statusptr)->line, \
100  (statusptr)->Id, (statement), \
101  (statusptr)->statusDescription ) : 0 )
102 
103 #define LALWarning( statusptr, warning ) \
104  ( lalDebugLevel & LALWARNING ? \
105  LALPrintError( "Warning[%d]: function %s, file %s, line %d, %s\n" \
106  " %s\n", (statusptr)->level, (statusptr)->function, \
107  (statusptr)->file, (statusptr)->line, (statusptr)->Id, (warning) ) \
108  : 0 )
109 
110 #define LALInfo( statusptr, info ) \
111  ( lalDebugLevel & LALINFO ? \
112  LALPrintError( "Info[%d]: function %s, file %s, line %d, %s\n" \
113  " %s\n", (statusptr)->level, (statusptr)->function, \
114  (statusptr)->file, (statusptr)->line, (statusptr)->Id, (info) ) \
115  : 0 )
116 
117 #define LALTrace( statusptr, exitflg ) \
118  ( lalDebugLevel & LALTRACE ? \
119  LALPrintError( "%s[%d]: function %s, file %s, line %d, %s\n", \
120  (exitflg) ? "Leave" : "Enter", (statusptr)->level, \
121  (statusptr)->function, (statusptr)->file, (statusptr)->line, \
122  (statusptr)->Id ) \
123  : 0 )
124 
125 #endif /* LAL_STATUS_MACROS_DISABLED */
126 
127 /*
128  * Error handlers for LALApps applications
129  */
130 
131 typedef int ( *lal_errhandler_t )(
132  LALStatus *,
133  const char *func,
134  const char *file,
135  const int line,
136  volatile const char *id
137  );
138 
139 #define LAL_ERR_DFLT LAL_ERR_ABRT
141 
142 extern int LAL_ERR_EXIT(
143  LALStatus *,
144  const char *func,
145  const char *file,
146  const int line,
147  volatile const char *id
148  );
149 extern int LAL_ERR_ABRT(
150  LALStatus *,
151  const char *func,
152  const char *file,
153  const int line,
154  volatile const char *id
155  );
156 extern int LAL_ERR_RTRN(
157  LALStatus *,
158  const char *func,
159  const char *file,
160  const int line,
161  volatile const char *id
162  );
163 
164 #define LAL_CALL( function, statusptr ) \
165  ((function),lal_errhandler(statusptr,#function,__FILE__,__LINE__,"$Id$"))
166 
167 #endif /* SWIG */
168 
169 /*
170  * Error codes and corresponding error messages.
171  */
172 
173 #define LAL_FAIL_ERR XLAL_EFAILED
174 #define LAL_FAIL_MSG "operation failed"
175 #define LAL_NULL_ERR XLAL_EFAULT
176 #define LAL_NULL_MSG "unexpected NULL pointer"
177 #define LAL_NNULL_ERR XLAL_EFAULT
178 #define LAL_NNULL_MSG "unexpected non-NULL pointer"
179 #define LAL_NOMEM_ERR XLAL_ENOMEM
180 #define LAL_NOMEM_MSG "out of memory"
181 #define LAL_RANGE_ERR XLAL_ERANGE
182 #define LAL_RANGE_MSG "parameter out of range"
183 #define LAL_BADPARM_ERR XLAL_EINVAL
184 #define LAL_BADPARM_MSG "invalid parameter value"
185 
186 #if 0
187 { /* so that editors will match succeeding brace */
188 #elif defined(__cplusplus)
189 }
190 #endif
191 
192 #endif /* _LALERROR_H */
void FREESTATUSPTR(LALStatus *status)
Definition: LALError.c:309
void REPORTSTATUS(LALStatus *status)
Definition: LALError.c:322
int LAL_ERR_ABRT(LALStatus *, const char *func, const char *file, const int line, volatile const char *id)
Definition: LALError.c:381
int LAL_ERR_EXIT(LALStatus *, const char *func, const char *file, const int line, volatile const char *id)
Definition: LALError.c:365
int(* lalRaiseHook)(int, const char *,...)
Definition: LALError.c:57
int LALPrepareAbort(LALStatus *status, const INT4 code, const char *mesg, const char *file, const int line)
Definition: LALError.c:244
#define LALError(statusptr, statement)
Definition: LALError.h:95
void(* lalAbortHook)(const char *,...)
Definition: LALError.c:75
#define LALInfo(statusptr, info)
Definition: LALError.h:110
#define LALWarning(statusptr, warning)
Definition: LALError.h:103
int LALDetatchStatusPtr(LALStatus *status, const char *file, const int line)
Definition: LALError.c:225
int(* lal_errhandler_t)(LALStatus *, const char *func, const char *file, const int line, volatile const char *id)
Definition: LALError.h:131
lal_errhandler_t lal_errhandler
Definition: LALError.c:363
int LALPrepareAssertFail(LALStatus *status, const INT4 code, const char *mesg, const char *statement, const char *file, const int line)
Definition: LALError.c:264
int LALCheckStatusPtr(LALStatus *status, const char *statement, const char *file, const int line)
Definition: LALError.c:285
int LAL_ERR_RTRN(LALStatus *, const char *func, const char *file, const int line, volatile const char *id)
Definition: LALError.c:397
#define LALTrace(statusptr, exitflg)
Definition: LALError.h:117
int LALPrepareReturn(LALStatus *status, const char *file, const int line)
Definition: LALError.c:182
int LALInitStatus(LALStatus *status, const char *function, const char *id, const char *file, const int line)
Definition: LALError.c:149
int LALAttatchStatusPtr(LALStatus *status, const char *file, const int line)
Definition: LALError.c:200
int32_t INT4
Four-byte signed integer.
int LALRaise(int sig, const char *fmt,...)
Definition: LALError.c:58
void LALAbort(const char *fmt,...)
Definition: LALError.c:76
int LALPrintError(const char *fmt,...)
Definition: LALError.c:46
LAL status structure, see The LALStatus structure for more details.
Definition: LALDatatypes.h:947