LAL  7.2.0.1-a5e7375
XLALError.c
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2007 Jolien Creighton, Kipp Cannon
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 /* - NOTE: API is doxygen-documented in header file XLALError.h - */
21 
22 #include <config.h>
23 
24 #include <math.h>
25 #include <stdio.h>
26 #include <stdarg.h>
27 #include <stdlib.h>
28 
29 #ifdef HAVE_EXECINFO_H
30 #include <execinfo.h>
31 #define BACKTRACE_LEVELMAX 0100
32 #endif
33 
34 #include <lal/XLALError.h>
35 #include <lal/LALStdlib.h>
36 
37 #ifdef __GNUC__
38 #define UNUSED __attribute__ ((unused))
39 #else
40 #define UNUSED
41 #endif
42 
43 /*
44  *
45  * Routines to print generic error messages and warning messages.
46  *
47  */
48 
49 /* Prints an error message if error printing is enabled by lalDebugLevel. */
50 int XLALVPrintError(const char *fmt, va_list ap)
51 {
52  return (lalDebugLevel & LALERROR) ? vfprintf(stderr, fmt, ap) : 0;
53 }
54 
55 /* Prints a warning message if warning printing is enabled by lalDebugLevel. */
56 int XLALVPrintWarning(const char *fmt, va_list ap)
57 {
58  return (lalDebugLevel & LALWARNING) ? vfprintf(stderr, fmt, ap) : 0;
59 }
60 
61 /* Prints an info message if info printing is enabled by lalDebugLevel. */
62 int XLALVPrintInfo(const char *fmt, va_list ap)
63 {
64  return (lalDebugLevel & LALINFO) ? vfprintf(stderr, fmt, ap) : 0;
65 }
66 
67 /* Prints an error message if error printing is enabled by lalDebugLevel. */
68 int XLALPrintError(const char *fmt, ...)
69 {
70  int n = 0;
71  va_list ap;
72  va_start(ap, fmt);
73  n = XLALVPrintError(fmt, ap);
74  va_end(ap);
75  return n;
76 }
77 
78 /* Prints a warning message if warning printing is enabled by lalDebugLevel. */
79 int XLALPrintWarning(const char *fmt, ...)
80 {
81  int n = 0;
82  va_list ap;
83  va_start(ap, fmt);
84  n = XLALVPrintWarning(fmt, ap);
85  va_end(ap);
86  return n;
87 }
88 
89 /* Prints an info message if info printing is enabled by lalDebugLevel. */
90 int XLALPrintInfo(const char *fmt, ...)
91 {
92  int n = 0;
93  va_list ap;
94  va_start(ap, fmt);
95  n = XLALVPrintInfo(fmt, ap);
96  va_end(ap);
97  return n;
98 }
99 
100 /*
101  * Prints a standard-formatted error message
102  * (if error printing is enabled by lalDebugLevel).
103  */
104 void XLALVPrintErrorMessage(const char *func, const char *file, int line,
105  const char *fmt, va_list ap)
106 {
107  XLALPrintError("XLAL Error");
108  if (func && *func)
109  XLALPrintError(" - %s", func);
110  if (file && *file)
111  XLALPrintError(" (%s:%d)", file, line);
112  XLALPrintError(": ");
113  XLALVPrintError(fmt, ap);
114  XLALPrintError("\n");
115  return;
116 }
117 
118 void XLALVPrintWarningMessage(const char *func, const char *file, int line,
119  const char *fmt, va_list ap)
120 {
121  XLALPrintWarning("XLAL Warning");
122  if (func && *func)
123  XLALPrintWarning(" - %s", func);
124  if (file && *file)
125  XLALPrintWarning(" (%s:%d)", file, line);
126  XLALPrintWarning(": ");
127  XLALVPrintWarning(fmt, ap);
128  XLALPrintWarning("\n");
129  return;
130 }
131 
132 void XLALVPrintInfoMessage(const char *func, const char *file, int line,
133  const char *fmt, va_list ap)
134 {
135  XLALPrintInfo("XLAL Info");
136  if (func && *func)
137  XLALPrintInfo(" - %s", func);
138  if (file && *file)
139  XLALPrintInfo(" (%s:%d)", file, line);
140  XLALPrintInfo(": ");
141  XLALVPrintInfo(fmt, ap);
142  XLALPrintInfo("\n");
143  return;
144 }
145 
146 void XLALPrintErrorMessage(const char *func, const char *file, int line,
147  const char *fmt, ...)
148 {
149  va_list ap;
150  va_start(ap, fmt);
151  XLALVPrintErrorMessage(func, file, line, fmt, ap);
152  va_end(ap);
153  return;
154 }
155 
156 void XLALPrintWarningMessage(const char *func, const char *file, int line,
157  const char *fmt, ...)
158 {
159  va_list ap;
160  va_start(ap, fmt);
161  XLALVPrintWarningMessage(func, file, line, fmt, ap);
162  va_end(ap);
163  return;
164 }
165 
166 void XLALPrintInfoMessage(const char *func, const char *file, int line,
167  const char *fmt, ...)
168 {
169  va_list ap;
170  va_start(ap, fmt);
171  XLALVPrintInfoMessage(func, file, line, fmt, ap);
172  va_end(ap);
173  return;
174 }
175 
176 
177 
178 /*
179  * Prints a progress bar at the "info" verbosity level.
180  */
181 int XLALPrintProgressBar(double fraction)
182 {
183  static const char mrk[] =
184  "+++++++++++++++++++++++++++++++++++++++++++++++++)";
185  static const char spc[] =
186  "-------------------------------------------------)";
187  int l = XLAL_NUM_ELEM(mrk) - 1;
188  int offset =
189  floor((fraction < 0.0 ? 0.0 : fraction >
190  1.0 ? 1.0 : fraction) * l + 0.5);
191 
192  return XLALPrintInfo("[%s%s %.1f%%", mrk + l - offset, spc + offset,
193  100.0 * fraction);
194 }
195 
196 /*
197  *
198  * Implementation of xlalErrno and XLALErrorHandler.
199  * If code must be POSIX thread safe then the code is somewhat more complicated.
200  *
201  */
202 
203 #ifndef LAL_PTHREAD_LOCK /* non-pthread-safe code */
204 
205 /* XLAL error number is just a global variable */
207 
208 /* XLALGetErrnoPtr just returns the address of the global variable */
209 int *XLALGetErrnoPtr(void)
210 {
211  return &xlalErrnoGlobal;
212 }
213 
214 /* XLAL error handler is just a global variable */
216 
217 /* XLALGetErrorHandlerPtr just returns the address of the global variable */
219 {
220  return &xlalErrorHandlerGlobal;
221 }
222 
223 #else /* pthread safe code */
224 
225 /* Note: malloc and free are used here rather than LALMalloc and LALFree...
226  * this is so that if a user checks for memory leaks within a thread before
227  * rejoining to the main thread (which shouldn't be done) then at least
228  * these routines won't report any leaks. */
229 
230 #ifdef HAVE_UNISTD_H
231 #include <unistd.h>
232 #endif
233 #include <pthread.h>
234 
235 pthread_key_t xlalErrnoKey;
236 pthread_once_t xlalErrnoKeyOnce = PTHREAD_ONCE_INIT;
237 pthread_key_t xlalErrorHandlerKey;
238 pthread_once_t xlalErrorHandlerKeyOnce = PTHREAD_ONCE_INIT;
239 
240 /* routine to free the XLAL error number pointer */
241 static void XLALDestroyErrnoPtr(void *xlalErrnoPtr)
242 {
243  free(xlalErrnoPtr);
244  return;
245 }
246 
247 /* routine to free the XLAL error handler pointer */
248 static void XLALDestroyErrorHandlerPtr(void *xlalErrorHandlerPtr)
249 {
250  free(xlalErrorHandlerPtr);
251  return;
252 }
253 
254 /* routine to create the XLAL error number key */
255 static void XLALCreateErrnoKey(void)
256 {
257  pthread_key_create(&xlalErrnoKey, XLALDestroyErrnoPtr);
258  return;
259 }
260 
261 /* routine to create the XLAL error handler key */
262 static void XLALCreateErrorHandlerKey(void)
263 {
264  pthread_key_create(&xlalErrorHandlerKey, XLALDestroyErrorHandlerPtr);
265  return;
266 }
267 
268 /* return the pointer to the XLAL error number in this thread */
269 int *XLALGetErrnoPtr(void)
270 {
271  int *xlalErrnoPtr;
272 
273  /* create key on the first call only */
274  pthread_once(&xlalErrnoKeyOnce, XLALCreateErrnoKey);
275 
276  /* get the pointer to the XLAL error number in this thread */
277  xlalErrnoPtr = pthread_getspecific(xlalErrnoKey);
278  if (!xlalErrnoPtr) { /* haven't allocated pointer yet... do it now */
279  xlalErrnoPtr = malloc(sizeof(*xlalErrnoPtr));
280  if (!xlalErrnoPtr)
282  ("could not set xlal error number: malloc failed\n");
283  *xlalErrnoPtr = 0; /* raises segv if memory allocation fails */
284  /* now set the value of the pointer in this thread in the key */
285  if (pthread_setspecific(xlalErrnoKey, xlalErrnoPtr))
287  ("could not set xlal error number: pthread_setspecific failed\n");
288  }
289  return xlalErrnoPtr;
290 }
291 
292 /* return the pointer to the XLAL error handler in this thread */
294 {
295  XLALErrorHandlerType **xlalErrorHandlerPtr;
296 
297  /* create key on the first call only */
298  pthread_once(&xlalErrorHandlerKeyOnce, XLALCreateErrorHandlerKey);
299 
300  /* get the pointer to the XLAL error handler in this thread */
301  xlalErrorHandlerPtr = pthread_getspecific(xlalErrorHandlerKey);
302  if (!xlalErrorHandlerPtr) { /* haven't allocated pointer yet... do it now */
303  xlalErrorHandlerPtr = malloc(sizeof(*xlalErrorHandlerPtr));
304  if (!xlalErrorHandlerPtr)
306  ("could not set xlal error handler: malloc failed\n");
307  *xlalErrorHandlerPtr = NULL; /* raises segv if memory allocation fails */
308  /* now set the value of the pointer in this thread in the key */
309  if (pthread_setspecific(xlalErrorHandlerKey, xlalErrorHandlerPtr))
311  ("could not set xlal error handler: pthread_setspecific failed\n");
312  }
313  return xlalErrorHandlerPtr;
314 }
315 
316 #endif /* end of pthread-safe code */
317 
318 
319 /*
320  *
321  * Here are the routines to set the error number or error handler.
322  *
323  */
324 
325 
326 /* Set the XLAL error number to errnum. */
327 int XLALSetErrno(int errnum)
328 {
329  if (errnum == 0) {
330  xlalErrno = 0;
331  return xlalErrno;
332  }
333 
334  /*
335  * if this is an error indicating an internal error then set the bit
336  * that indicates this; otherwise, xlalErrno should presumably be zero
337  */
338  if (errnum & XLAL_EFUNC) {
339  xlalErrno |= XLAL_EFUNC; /* make sure XLAL_EFUNC bit is set */
340  return xlalErrno;
341  }
342 
343  /*
344  * if xlalErrno is not zero, probably forgot to deal with previous
345  * error
346  */
347  if (xlalErrno)
348  XLAL_PRINT_WARNING("Ignoring previous error (xlalErrno=%d) %s\n",
350  xlalErrno = errnum;
351  return xlalErrno;
352 }
353 
354 
355 /* Gets the basic error number ignoring the internal-function-failed flag. */
357 {
358  return xlalErrno & ~XLAL_EFUNC;
359 }
360 
361 
362 /* Clears the XLAL error number. */
363 int XLALClearErrno(void)
364 {
365  int olderrno = xlalErrno;
366  xlalErrno = 0;
367  return olderrno;
368 }
369 
370 
371 /* Set the XLAL error handler to newHandler; return the old handler. */
373  newHandler)
374 {
375  XLALErrorHandlerType *oldHandler;
376  oldHandler = XLALErrorHandler;
377  XLALErrorHandler = newHandler;
378  return oldHandler;
379 }
380 
381 
382 /* Set the XLAL error handler to the default handler; return the old handler. */
384 {
385  XLALErrorHandlerType *oldHandler;
386  oldHandler = XLALErrorHandler;
388  return oldHandler;
389 }
390 
391 /* Set the XLAL error handler to a silent handler; return the old handler. */
393 {
394  XLALErrorHandlerType *oldHandler;
395  oldHandler = XLALErrorHandler;
397  return oldHandler;
398 }
399 
400 
401 /*
402  *
403  * Routines to give the error message associated with a given error number.
404  *
405  */
406 
407 
408 /* Return the error message associated with an error number or return value. */
409 const char *XLALErrorString(int code)
410 {
411 
412  if (code <= 0) { /* this is a return code, not an error number */
413  if (code == 0)
414  return "Success";
415  else if (code == -1)
416  return "Failure";
417  else
418  return "Unknown return code";
419  }
420 
421  /* check to see if an internal function call has failed, but the error
422  * number was not "or"ed against the mask XLAL_EFUNC */
423  if (code == XLAL_EFUNC)
424  return "Internal function call failed";
425 
426  /* use this to report error strings... deals with possible mask for
427  * errors arising from internal function calls */
428 # define XLAL_ERROR_STRING(s) \
429  ( ( code & XLAL_EFUNC ) ? "Internal function call failed: " s : (const char *) s )
430  switch (code & ~XLAL_EFUNC) {
431  /* these are standard error numbers */
432  case XLAL_ENOENT:
433  return XLAL_ERROR_STRING("No such file or directory");
434  case XLAL_EIO:
435  return XLAL_ERROR_STRING("I/O error");
436  case XLAL_ENOMEM:
437  return XLAL_ERROR_STRING("Memory allocation error");
438  case XLAL_EFAULT:
439  return XLAL_ERROR_STRING("Invalid pointer");
440  case XLAL_EINVAL:
441  return XLAL_ERROR_STRING("Invalid argument");
442  case XLAL_EDOM:
443  return XLAL_ERROR_STRING("Input domain error");
444  case XLAL_ERANGE:
445  return XLAL_ERROR_STRING("Output range error");
446  case XLAL_ENOSYS:
447  return XLAL_ERROR_STRING("Function not implemented");
448 
449  /* extended error numbers start at 128 ...
450  * should be beyond normal errnos */
451 
452  /* these are common errors for XLAL functions */
453  case XLAL_EFAILED:
454  return XLAL_ERROR_STRING("Generic failure");
455  case XLAL_EBADLEN:
456  return XLAL_ERROR_STRING("Inconsistent or invalid vector length");
457  case XLAL_ESIZE:
458  return XLAL_ERROR_STRING("Wrong size");
459  case XLAL_EDIMS:
460  return XLAL_ERROR_STRING("Wrong dimensions");
461  case XLAL_ETYPE:
462  return XLAL_ERROR_STRING("Wrong or unknown type");
463  case XLAL_ETIME:
464  return XLAL_ERROR_STRING("Invalid time");
465  case XLAL_EFREQ:
466  return XLAL_ERROR_STRING("Invalid freqency");
467  case XLAL_EUNIT:
468  return XLAL_ERROR_STRING("Invalid units");
469  case XLAL_ENAME:
470  return XLAL_ERROR_STRING("Wrong name");
471  case XLAL_EDATA:
472  return XLAL_ERROR_STRING("Invalid data");
473 
474  /* user-defined errors */
475  case XLAL_EUSR0:
476  return XLAL_ERROR_STRING("User-defined error 0");
477  case XLAL_EUSR1:
478  return XLAL_ERROR_STRING("User-defined error 1");
479  case XLAL_EUSR2:
480  return XLAL_ERROR_STRING("User-defined error 2");
481  case XLAL_EUSR3:
482  return XLAL_ERROR_STRING("User-defined error 3");
483  case XLAL_EUSR4:
484  return XLAL_ERROR_STRING("User-defined error 4");
485  case XLAL_EUSR5:
486  return XLAL_ERROR_STRING("User-defined error 5");
487  case XLAL_EUSR6:
488  return XLAL_ERROR_STRING("User-defined error 6");
489  case XLAL_EUSR7:
490  return XLAL_ERROR_STRING("User-defined error 7");
491  case XLAL_EUSR8:
492  return XLAL_ERROR_STRING("User-defined error 8");
493  case XLAL_EUSR9:
494  return XLAL_ERROR_STRING("User-defined error 9");
495 
496  /* external or internal errors */
497  case XLAL_ESYS:
498  return XLAL_ERROR_STRING("System error");
499  case XLAL_EERR:
500  return XLAL_ERROR_STRING("Internal error");
501 
502  /* specific mathematical and numerical errors start at 256 */
503 
504  /* IEEE floating point errors */
505  case XLAL_EFPINVAL:
506  return
508  ("Invalid floating point operation, eg sqrt(-1), 0/0");
509  case XLAL_EFPDIV0:
510  return XLAL_ERROR_STRING("Division by zero floating point error");
511  case XLAL_EFPOVRFLW:
512  return XLAL_ERROR_STRING("Floating point overflow error");
513  case XLAL_EFPUNDFLW:
514  return XLAL_ERROR_STRING("Floating point underflow error");
515  case XLAL_EFPINEXCT:
516  return XLAL_ERROR_STRING("Floating point inexact error");
517 
518  /* numerical algorithm errors */
519  case XLAL_EMAXITER:
520  return XLAL_ERROR_STRING("Exceeded maximum number of iterations");
521  case XLAL_EDIVERGE:
522  return XLAL_ERROR_STRING("Series is diverging");
523  case XLAL_ESING:
524  return XLAL_ERROR_STRING("Apparent singularity detected");
525  case XLAL_ETOL:
526  return XLAL_ERROR_STRING("Failed to reach specified tolerance");
527  case XLAL_ELOSS:
528  return XLAL_ERROR_STRING("Loss of accuracy");
529 
530  /* unrecognized error number */
531  default:
532  return "Unknown error";
533  }
534 # undef XLAL_ERROR_STRING
535  return NULL; /* impossible to get here */
536 }
537 
538 /* Print an error message associated with an error number or return code. */
539 void XLALPerror(const char *func, const char *file, int line, int code)
540 {
541  if (code > 0)
542  XLALPrintError("XLAL Error");
543  else
544  XLALPrintError("XLAL Result");
545  if (func && *func)
546  XLALPrintError(" - %s", func);
547  if (file && *file)
548  XLALPrintError(" (%s:%d)", file, line);
549  XLALPrintError(": %s\n", XLALErrorString(code));
550  return;
551 }
552 
553 
554 /*
555  *
556  * Here is the default error handler.
557  *
558  */
559 
560 /* Default XLAL error handler */
561 void XLALDefaultErrorHandler(const char *func, const char *file, int line,
562  int errnum)
563 {
564  XLALPerror(func, file, line, errnum);
565  return;
566 }
567 
568 /* Silent XLAL error handler */
569 void XLALSilentErrorHandler(const char UNUSED * func,
570  const char UNUSED * file, int UNUSED line,
571  int UNUSED errnum)
572 {
573  return;
574 }
575 
576 
577 /*
578  *
579  * Routine to set the error number and invoke the current error handler.
580  *
581  */
582 void XLALError(const char *func, const char *file, int line, int errnum)
583 {
584  XLALSetErrno(errnum);
585  if (!XLALErrorHandler)
587  XLALErrorHandler(func, file, line, xlalErrno);
588  return;
589 }
590 
591 
592 /*
593  *
594  * Useful standard error handlers
595  *
596  */
597 
598 /* XLAL error handler to abort on error. */
599 void XLALAbortErrorHandler(const char *func, const char *file, int line,
600  int errnum)
601 {
602  XLALPerror(func, file, line, errnum);
603  abort();
604 }
605 
606 /* XLAL error handler to exit on error. */
607 void XLALExitErrorHandler(const char *func, const char *file, int line,
608  int errnum)
609 {
610  XLALPerror(func, file, line, errnum);
611  exit(1);
612 }
613 
614 /* XLAL error handler to abort on error and print a backtrace (if possible). */
615 void XLALBacktraceErrorHandler(const char *func, const char *file,
616  int line, int errnum)
617 {
618  XLALPerror(func, file, line, errnum);
619 #if defined(HAVE_BACKTRACE) && defined(BACKTRACE_LEVELMAX)
620  void *callstack[BACKTRACE_LEVELMAX];
621  size_t frames = backtrace(callstack, BACKTRACE_LEVELMAX);
622  fprintf(stderr, "backtrace:\n");
623  backtrace_symbols_fd(callstack, frames, fileno(stderr));
624 #endif
625  abort();
626 }
void XLALDefaultErrorHandler(const char *func, const char *file, int line, int errnum)
The default XLAL error handler.
Definition: XLALError.c:561
System error.
Definition: XLALError.h:443
int XLALPrintWarning(const char *fmt,...)
Definition: XLALError.c:79
User-defined error 3.
Definition: XLALError.h:434
void XLALPrintWarningMessage(const char *func, const char *file, int line, const char *fmt,...)
Definition: XLALError.c:156
enable error messages
Definition: LALDebugLevel.h:44
int pthread_key_create(pthread_key_t *key, destr_function destr)
Definition: qthread.c:82
int pthread_once(pthread_once_t *once_control, void(*init_routine)(void))
Definition: qthread.c:52
XLALErrorHandlerType ** XLALGetErrorHandlerPtr(void)
Function to return pointer to the XLAL error handler function pointer.
Definition: XLALError.c:218
int XLALGetBaseErrno(void)
Gets the XLAL base error number ignoring the internal-function-failed flag.
Definition: XLALError.c:356
IEEE Floating point overflow error.
Definition: XLALError.h:451
Wrong size.
Definition: XLALError.h:421
XLALErrorHandlerType * xlalErrorHandlerGlobal
Definition: XLALError.c:215
XLALErrorHandlerType * XLALSetSilentErrorHandler(void)
Sets the error handler to a silent handler and returns the old handler.
Definition: XLALError.c:392
void XLALVPrintErrorMessage(const char *func, const char *file, int line, const char *fmt, va_list ap)
Print an error message with standard XLAL formatting (if error messages are enabled by lalDebugLevel)...
Definition: XLALError.c:104
void XLALErrorHandlerType(const char *func, const char *file, int line, int errnum)
The XLAL error handler type.
Definition: XLALError.h:497
void XLALVPrintWarningMessage(const char *func, const char *file, int line, const char *fmt, va_list ap)
Print an warning message with standard XLAL formatting (if warning messages are enabled by lalDebugLe...
Definition: XLALError.c:118
Apparent singularity detected.
Definition: XLALError.h:458
void XLALError(const char *func, const char *file, int line, int errnum)
Routine to set the XLAL error number and invoke the XLAL error handler.
Definition: XLALError.c:582
#define xlalErrno
Modifiable lvalue containing the XLAL error number.
Definition: XLALError.h:572
int XLALVPrintWarning(const char *fmt, va_list ap)
Prints a warning message if warning printing is enabled by lalDebugLevel.
Definition: XLALError.c:56
int * XLALGetErrnoPtr(void)
Function to return pointer to the XLAL error number.
Definition: XLALError.c:209
I/O error.
Definition: XLALError.h:407
User-defined error 8.
Definition: XLALError.h:439
Internal error.
Definition: XLALError.h:444
int XLALVPrintInfo(const char *fmt, va_list ap)
Prints an info message if info printing is enabled by lalDebugLevel.
Definition: XLALError.c:62
const char * XLALErrorString(int code)
Returns the error message associated with an error number.
Definition: XLALError.c:409
Series is diverging.
Definition: XLALError.h:457
int xlalErrnoGlobal
Definition: XLALError.c:206
Output range error.
Definition: XLALError.h:412
Invalid time.
Definition: XLALError.h:424
#define fprintf
void XLALPrintErrorMessage(const char *func, const char *file, int line, const char *fmt,...)
Definition: XLALError.c:146
XLALErrorHandlerType * XLALSetErrorHandler(XLALErrorHandlerType *newHandler)
Sets the error handler to a new handler and returns the old handler.
Definition: XLALError.c:372
User-defined error 7.
Definition: XLALError.h:438
void XLALPrintInfoMessage(const char *func, const char *file, int line, const char *fmt,...)
Definition: XLALError.c:166
User-defined error 6.
Definition: XLALError.h:437
IEEE Division by zero floating point error.
Definition: XLALError.h:450
IEEE Floating point inexact error.
Definition: XLALError.h:453
IEEE Invalid floating point operation, eg sqrt(-1), 0/0.
Definition: XLALError.h:449
int XLALPrintInfo(const char *fmt,...)
Definition: XLALError.c:90
int XLALClearErrno(void)
Clears the XLAL error number, returns the old value.
Definition: XLALError.c:363
Invalid pointer.
Definition: XLALError.h:409
enable info messages
Definition: LALDebugLevel.h:46
XLALErrorHandlerType * XLALSetDefaultErrorHandler(void)
Sets the error handler to the default handler and returns the old handler.
Definition: XLALError.c:383
int XLALSetErrno(int errnum)
Sets the XLAL error number to errnum, returns the new value.
Definition: XLALError.c:327
Input domain error.
Definition: XLALError.h:411
void XLALAbortErrorHandler(const char *func, const char *file, int line, int errnum)
The XLAL error handler that raises SIGABRT.
Definition: XLALError.c:599
Invalid freqency.
Definition: XLALError.h:425
Function not implemented.
Definition: XLALError.h:413
#define lalDebugLevel
Definition: LALDebugLevel.h:56
IEEE Floating point underflow error.
Definition: XLALError.h:452
Wrong dimensions.
Definition: XLALError.h:422
int XLALPrintError(const char *fmt,...)
Definition: XLALError.c:68
Failed to reach specified tolerance.
Definition: XLALError.h:459
int XLALPrintProgressBar(double fraction)
Prints a progress bar at the "info" verbosity level.
Definition: XLALError.c:181
enable warning messages
Definition: LALDebugLevel.h:45
void XLALBacktraceErrorHandler(const char *func, const char *file, int line, int errnum)
The XLAL error handler that prints a function call backtrace then raises SIGABRT. ...
Definition: XLALError.c:615
void(* lalAbortHook)(const char *,...)
Definition: LALError.c:75
User-defined error 1.
Definition: XLALError.h:432
User-defined error 2.
Definition: XLALError.h:433
Memory allocation error.
Definition: XLALError.h:408
Invalid data.
Definition: XLALError.h:428
void XLALExitErrorHandler(const char *func, const char *file, int line, int errnum)
The XLAL error handler that calls exit.
Definition: XLALError.c:607
void * pthread_getspecific(pthread_key_t key)
Definition: qthread.c:143
int XLALVPrintError(const char *fmt, va_list ap)
Prints an error message if error printing is enabled by lalDebugLevel.
Definition: XLALError.c:50
Exceeded maximum number of iterations.
Definition: XLALError.h:456
void XLALVPrintInfoMessage(const char *func, const char *file, int line, const char *fmt, va_list ap)
Print an error message with standard XLAL formatting (if error messages are enabled by lalDebugLevel)...
Definition: XLALError.c:132
Generic failure.
Definition: XLALError.h:419
int pthread_setspecific(pthread_key_t key, const void *pointer)
Definition: qthread.c:128
Internal function call failed bit: "or" this with existing error number.
Definition: XLALError.h:463
User-defined error 9.
Definition: XLALError.h:440
No such file or directory.
Definition: XLALError.h:406
Invalid units.
Definition: XLALError.h:426
Invalid argument.
Definition: XLALError.h:410
void XLALPerror(const char *func, const char *file, int line, int code)
Prints an error message for a particular error code in a standard format.
Definition: XLALError.c:539
#define XLAL_PRINT_WARNING(...)
Macro that will print a warning message with a standard format.
Definition: XLALError.h:271
Inconsistent or invalid length.
Definition: XLALError.h:420
Wrong or unknown type.
Definition: XLALError.h:423
Wrong name.
Definition: XLALError.h:427
User-defined error 5.
Definition: XLALError.h:436
#define XLALErrorHandler
Modifiable lvalue containing the XLAL error handler.
Definition: XLALError.h:573
User-defined error 0.
Definition: XLALError.h:431
#define XLAL_ERROR_STRING(s)
void XLALSilentErrorHandler(const char UNUSED *func, const char UNUSED *file, int UNUSED line, int UNUSED errnum)
Definition: XLALError.c:569
#define XLAL_NUM_ELEM(x)
MACRO which gives the number of elements in a fixed-size array.
User-defined error 4.
Definition: XLALError.h:435
Loss of accuracy.
Definition: XLALError.h:460