X-shooter Pipeline Reference Manual 3.8.15
irplib_error.h
Go to the documentation of this file.
1/* $Id: irplib_error.h,v 1.4 2007-10-04 08:57:15 rhaigron Exp $
2 *
3 * This file is part of the irplib package
4 * Copyright (C) 2002,2003,2004,2005,2006 European Southern Observatory
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
19 */
20
21/*
22 * $Author: rhaigron $
23 * $Date: 2007-10-04 08:57:15 $
24 * $Revision: 1.4 $
25 * $Name: not supported by cvs2svn $
26 */
27
28#ifndef IRPLIB_ERROR_H
29#define IRPLIB_ERROR_H
30
31/*-----------------------------------------------------------------------------
32 Includes
33 -----------------------------------------------------------------------------*/
34
35#include <cpl.h>
36#include <xsh_msg.h>
37/*----------------------------------------------------------------------------*/
41/*----------------------------------------------------------------------------*/
44/*-----------------------------------------------------------------------------
45 Define
46 -----------------------------------------------------------------------------*/
47/* fixme: This is to avoid including irplib_utils.h which includes this file */
48#if defined HAVE_DECL___FUNC__ && !HAVE_DECL___FUNC__
49#ifndef __func__
50#define __func__ ""
51#endif
52#endif
53
54/*----------------------------------------------------------------------------*/
153/*----------------------------------------------------------------------------*/
154
155#define irplib_error_assure(CONDITION, ERROR_CODE, MSG, ACTION) \
156 do {\
157 if (cpl_error_get_code() != CPL_ERROR_NONE){ \
158 irplib_error_push(cpl_error_get_code(), \
159 ("An error occurred that was not caught: %s", \
160 cpl_error_get_where()) ); \
161 ACTION; \
162 } \
163 else if (!(CONDITION)) \
164 {\
165 irplib_error_push(ERROR_CODE, MSG); \
166 ACTION; \
167 } \
168 } while (0)
169
170/*----------------------------------------------------------------------------*/
180/*----------------------------------------------------------------------------*/
181#define irplib_error_push(ec, msg) \
182 do { \
183 xsh_irplib_error_set_msg msg; \
184 xsh_irplib_error_push_macro(__func__, ec, __FILE__, __LINE__); \
185 } while (0)
186
187
188
189/*----------------------------------------------------------------------------*/
222/*----------------------------------------------------------------------------*/
223#define irplib_error_dump(severity, trace_severity) \
224 xsh_irplib_error_dump_macro(__func__, __FILE__, __LINE__, \
225 severity, trace_severity)
226
227/*-----------------------------------------------------------------------------
228 Functions prototypes
229 -----------------------------------------------------------------------------*/
230
231void xsh_irplib_error_reset(void);
232
233/*
234 * The following functions should not be called directly ; but they must
235 * be exported in order to support the macro nature of the interface
236 */
237cpl_error_code xsh_irplib_error_push_macro(const char *func,
238 cpl_error_code ec,
239 const char *file,
240 unsigned int line);
241void xsh_irplib_error_dump_macro(const char *func,
242 const char *file,
243 unsigned int line,
244 cpl_msg_severity severity,
245 cpl_msg_severity trace_severity);
246
247void xsh_irplib_error_set_msg(const char *format, ...)
248#ifdef __GNUC__
249 __attribute__((format (printf, 1, 2)))
250#endif
251 ;
252
253#endif /* IRPLIB_ERROR_H */
254
cpl_error_code xsh_irplib_error_push_macro(const char *func, cpl_error_code ec, const char *file, unsigned int line)
Set or propagate an error.
Definition: irplib_error.c:259
void xsh_irplib_error_reset(void)
Reset the error state.
Definition: irplib_error.c:347
void xsh_irplib_error_dump_macro(const char *func, const char *file, unsigned int line, cpl_msg_severity severity, cpl_msg_severity trace_severity)
Print the error queue.
Definition: irplib_error.c:375
void xsh_irplib_error_set_msg(const char *format,...)
Temporarily store an error message.
Definition: irplib_error.c:325