LAL  7.1.7.1-15d842a
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 NOLALMACROS
86 
88 
90 
91 #endif
92 
93 #ifdef NDEBUG
94 
95 #define LALError( statusptr, statement ) (void)(0)
96 #define LALWarning( statusptr, warning ) (void)(0)
97 #define LALInfo( statusptr, info ) (void)(0)
98 #define LALTrace( statusptr, exitflg ) (void)(0)
99 
100 #else
101 
102 #ifndef NOLALMACROS
103 
104 #define LALError( statusptr, statement ) \
105  ( lalDebugLevel & LALERROR ? \
106  LALPrintError( "Error[%d] %d: function %s, file %s, line %d, %s\n" \
107  " %s %s\n", (statusptr)->level, (statusptr)->statusCode, \
108  (statusptr)->function, (statusptr)->file, (statusptr)->line, \
109  (statusptr)->Id, (statement), \
110  (statusptr)->statusDescription ) : 0 )
111 
112 #define LALWarning( statusptr, warning ) \
113  ( lalDebugLevel & LALWARNING ? \
114  LALPrintError( "Warning[%d]: function %s, file %s, line %d, %s\n" \
115  " %s\n", (statusptr)->level, (statusptr)->function, \
116  (statusptr)->file, (statusptr)->line, (statusptr)->Id, (warning) ) \
117  : 0 )
118 
119 #define LALInfo( statusptr, info ) \
120  ( lalDebugLevel & LALINFO ? \
121  LALPrintError( "Info[%d]: function %s, file %s, line %d, %s\n" \
122  " %s\n", (statusptr)->level, (statusptr)->function, \
123  (statusptr)->file, (statusptr)->line, (statusptr)->Id, (info) ) \
124  : 0 )
125 
126 #define LALTrace( statusptr, exitflg ) \
127  ( lalDebugLevel & LALTRACE ? \
128  LALPrintError( "%s[%d]: function %s, file %s, line %d, %s\n", \
129  (exitflg) ? "Leave" : "Enter", (statusptr)->level, \
130  (statusptr)->function, (statusptr)->file, (statusptr)->line, \
131  (statusptr)->Id ) \
132  : 0 )
133 
134 #endif /* NOLALMACROS */
135 
136 #endif /* NDEBUG */
137 
138 /*
139  * Error handlers for LALApps applications
140  */
141 
142 typedef int ( *lal_errhandler_t )(
143  LALStatus *,
144  const char *func,
145  const char *file,
146  const int line,
147  volatile const char *id
148  );
149 
150 #define LAL_ERR_DFLT LAL_ERR_ABRT
152 
153 extern int LAL_ERR_EXIT(
154  LALStatus *,
155  const char *func,
156  const char *file,
157  const int line,
158  volatile const char *id
159  );
160 extern int LAL_ERR_ABRT(
161  LALStatus *,
162  const char *func,
163  const char *file,
164  const int line,
165  volatile const char *id
166  );
167 extern int LAL_ERR_RTRN(
168  LALStatus *,
169  const char *func,
170  const char *file,
171  const int line,
172  volatile const char *id
173  );
174 
175 #define LAL_CALL( function, statusptr ) \
176  ((function),lal_errhandler(statusptr,#function,__FILE__,__LINE__,"$Id$"))
177 
178 #endif /* SWIG */
179 
180 /*
181  * Error codes and corresponding error messages.
182  */
183 
184 #define LAL_FAIL_ERR XLAL_EFAILED
185 #define LAL_FAIL_MSG "operation failed"
186 #define LAL_NULL_ERR XLAL_EFAULT
187 #define LAL_NULL_MSG "unexpected NULL pointer"
188 #define LAL_NNULL_ERR XLAL_EFAULT
189 #define LAL_NNULL_MSG "unexpected non-NULL pointer"
190 #define LAL_NOMEM_ERR XLAL_ENOMEM
191 #define LAL_NOMEM_MSG "out of memory"
192 #define LAL_RANGE_ERR XLAL_ERANGE
193 #define LAL_RANGE_MSG "parameter out of range"
194 #define LAL_BADPARM_ERR XLAL_EINVAL
195 #define LAL_BADPARM_MSG "invalid parameter value"
196 
197 #if 0
198 { /* so that editors will match succeeding brace */
199 #elif defined(__cplusplus)
200 }
201 #endif
202 
203 #endif /* _LALERROR_H */
int LAL_ERR_RTRN(LALStatus *, const char *func, const char *file, const int line, volatile const char *id)
Definition: LALError.c:407
int LALPrepareAssertFail(LALStatus *status, const INT4 code, const char *mesg, const char *statement, const char *file, const int line)
Definition: LALError.c:274
lal_errhandler_t lal_errhandler
Definition: LALError.c:373
#define LALWarning(statusptr, warning)
Definition: LALError.h:112
#define LALInfo(statusptr, info)
Definition: LALError.h:119
int LAL_ERR_EXIT(LALStatus *, const char *func, const char *file, const int line, volatile const char *id)
Definition: LALError.c:375
int LALPrepareAbort(LALStatus *status, const INT4 code, const char *mesg, const char *file, const int line)
Definition: LALError.c:254
int LALPrepareReturn(LALStatus *status, const char *file, const int line)
Definition: LALError.c:192
int LALRaise(int sig, const char *fmt,...)
Definition: LALError.c:58
int(* lal_errhandler_t)(LALStatus *, const char *func, const char *file, const int line, volatile const char *id)
Definition: LALError.h:142
LAL status structure, see The LALStatus structure for more details.
Definition: LALDatatypes.h:947
#define LALError(statusptr, statement)
Definition: LALError.h:104
int LALDetatchStatusPtr(LALStatus *status, const char *file, const int line)
Definition: LALError.c:235
void REPORTSTATUS(LALStatus *status)
Definition: LALError.c:332
#define LALTrace(statusptr, exitflg)
Definition: LALError.h:126
void(* lalAbortHook)(const char *,...)
Definition: LALError.c:75
int32_t INT4
Four-byte signed integer.
int(* lalRaiseHook)(int, const char *,...)
Definition: LALError.c:57
int LALCheckStatusPtr(LALStatus *status, const char *statement, const char *file, const int line)
Definition: LALError.c:295
int LALInitStatus(LALStatus *status, const char *function, const char *id, const char *file, const int line)
Definition: LALError.c:159
void FREESTATUSPTR(LALStatus *status)
Definition: LALError.c:319
int LALAttatchStatusPtr(LALStatus *status, const char *file, const int line)
Definition: LALError.c:210
int LALPrintError(const char *fmt,...)
Definition: LALError.c:46
int LAL_ERR_ABRT(LALStatus *, const char *func, const char *file, const int line, volatile const char *id)
Definition: LALError.c:391
void LALAbort(const char *fmt,...)
Definition: LALError.c:76