SINFONI Pipeline Reference Manual  2.5.2
sinfo_error.h
1 /*
2  * This file is part of the ESO SINFONI Pipeline
3  * Copyright (C) 2004,2005 European Southern Observatory
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
18  */
19 
20 /*
21  * $Author: amodigli $
22  * $Date: 2007-10-26 09:42:36 $
23  * $Revision: 1.13 $
24  * $Name: not supported by cvs2svn $
25  * $Log: not supported by cvs2svn $
26  * Revision 1.12 2007/08/14 10:01:41 amodigli
27  * added sinfo_stop_if_error
28  *
29  * Revision 1.11 2007/08/11 10:46:18 amodigli
30  * clean
31  *
32  * Revision 1.9 2007/08/08 11:17:26 amodigli
33  * change to support CPL31 & CPL40
34  *
35  * Revision 1.8 2007/06/06 07:10:45 amodigli
36  * replaced tab with 4 spaces
37  *
38  * Revision 1.7 2006/11/21 11:56:10 amodigli
39  * replaced __func__ by cpl_func
40  *
41  * Revision 1.6 2006/10/16 07:26:23 amodigli
42  * shortened line length
43  *
44  * Revision 1.5 2006/10/13 08:09:42 amodigli
45  * shorten line length
46  *
47  * Revision 1.4 2006/10/13 06:34:40 amodigli
48  * shorten line length
49  *
50  * Revision 1.3 2006/10/04 06:17:45 amodigli
51  * added doxygen doc
52  *
53  * Revision 1.2 2006/07/31 06:33:34 amodigli
54  * fixed bug in ck0 macro
55  *
56  * Revision 1.1 2006/05/30 09:09:37 amodigli
57  * added to repository
58  *
59  *
60  */
61 
62 #ifndef SINFO_ERROR_H
63 #define SINFO_ERROR_H
64 
69 /*-----------------------------------------------------------------------------
70  Includes
71 -----------------------------------------------------------------------------*/
72 #include <cpl_error.h>
73 #include <cpl.h>
74 
75 #include <irplib_utils.h>
76 /*-----------------------------------------------------------------------------
77  Defines
78 -----------------------------------------------------------------------------*/
79 /* To save some key-strokes, use the irplib error handling macros
80  under different (shorter) names.
81  Additionally, irplib macros require the VA_ARGS to be enclosed in (),
82 */
83 
84 #define assure(BOOL, CODE, ...) \
85  cpl_error_ensure(BOOL, CODE, goto cleanup,__VA_ARGS__)
86 
87 #define assure_nomsg(BOOL, CODE, ...) \
88  cpl_error_ensure(BOOL, CODE, goto cleanup,__VA_ARGS__)
89 
90 #define sinfo_stop_if_error() \
91  do if(cpl_error_get_code()) { \
92  cpl_msg_error(__func__,"Traced error"); \
93  irplib_trace(); \
94  goto cleanup; \
95  } while (0)
96 
97 #define ck0(IEXP, ...) \
98  cpl_error_ensure(IEXP == 0, CPL_ERROR_UNSPECIFIED, \
99  goto cleanup,__VA_ARGS__)
100 
101 #define ck0_nomsg(IEXP) ck0(IEXP," ")
102 
103 #define cknull(NULLEXP, ...) \
104  cpl_error_ensure((NULLEXP) != NULL, \
105  CPL_ERROR_UNSPECIFIED, goto cleanup,__VA_ARGS__)
106 
107 #define cknull_nomsg(NULLEXP) cknull(NULLEXP," ")
108 
109 #define check(CMD, ...) \
110  cpl_error_ensure((sinfo_msg_softer(), (CMD), sinfo_msg_louder(), \
111  cpl_error_get_code() == CPL_ERROR_NONE), \
112  cpl_error_get_code(), goto cleanup,__VA_ARGS__)
113 
114 #define check_nomsg(CMD) check(CMD, " ")
115 
116 #define passure(BOOL, ...) \
117  cpl_error_ensure(BOOL, CPL_ERROR_UNSPECIFIED, goto cleanup,\
118  ("Internal error. Please report to " \
119  PACKAGE_BUGREPORT " " __VA_ARGS__))
120  // Assumes that PACKAGE_BUGREPORT
121  //contains no formatting special characters
122 
123 
407 #endif