irplib_error.h

00001 /* $Id: irplib_error.h,v 1.9 2006/10/10 14:42:51 jmlarsen Exp $
00002  *
00003  * This file is part of the irplib package
00004  * Copyright (C) 2002,2003 European Southern Observatory
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02111-1307  USA
00019  */
00020 
00021 /*
00022  * $Author: jmlarsen $
00023  * $Date: 2006/10/10 14:42:51 $
00024  * $Revision: 1.9 $
00025  * $Name:  $
00026  */
00027 
00028 #ifndef IRPLIB_ERROR_H
00029 #define IRPLIB_ERROR_H
00030 
00031 /*-----------------------------------------------------------------------------
00032                                    Includes
00033  -----------------------------------------------------------------------------*/
00034 
00035 #include <cpl.h>
00036 /*----------------------------------------------------------------------------*/
00040 /*----------------------------------------------------------------------------*/
00043 /*-----------------------------------------------------------------------------
00044                                    Define
00045  -----------------------------------------------------------------------------*/
00046 
00047 /*----------------------------------------------------------------------------*/
00146 /*----------------------------------------------------------------------------*/
00147 
00148 #define irplib_error_assure(CONDITION, ERROR_CODE, MSG, ACTION)                \
00149   do {                                                                         \
00150       if (cpl_error_get_code() != CPL_ERROR_NONE)                              \
00151       {                                                                        \
00152           irplib_error_push(cpl_error_get_code(),                              \
00153                            ("An error occurred that was not caught: %s",       \
00154                            cpl_error_get_where()) );                           \
00155           ACTION;                                                              \
00156       }                                                                        \
00157       else if (!(CONDITION))                                                   \
00158       {                                                                        \
00159           irplib_error_push(ERROR_CODE, MSG);                                  \
00160           ACTION;                                                              \
00161       }                                                                        \
00162   } while (0)
00163 
00164 /*----------------------------------------------------------------------------*/
00174 /*----------------------------------------------------------------------------*/
00175 #define irplib_error_push(ec, msg)                                             \
00176       do {                                                                     \
00177         irplib_error_set_msg msg;                                              \
00178         irplib_error_push_macro(cpl_func, ec, __FILE__, __LINE__);             \
00179       } while (0)
00180 
00181 
00182 
00183 /*----------------------------------------------------------------------------*/
00216 /*----------------------------------------------------------------------------*/
00217 #define irplib_error_dump(severity, trace_severity)                            \
00218         irplib_error_dump_macro(cpl_func, __FILE__, __LINE__,                  \
00219                 severity, trace_severity) 
00220 
00221 /*-----------------------------------------------------------------------------
00222                                Functions prototypes
00223  -----------------------------------------------------------------------------*/
00224 
00225 void irplib_error_reset(void);
00226 
00227 /*
00228  * The following functions should not be called directly ; but they must
00229  * be exported in order to support the macro nature of the interface
00230  */
00231 void irplib_error_push_macro(const char *func,
00232                  cpl_error_code ec,
00233                  const char *file, 
00234                  unsigned int line);
00235 void irplib_error_dump_macro(const char *func,
00236                  const char *file,
00237                  unsigned int line,
00238                  cpl_msg_severity severity,
00239                  cpl_msg_severity trace_severity);
00240 
00241 void irplib_error_set_msg(const char *format, ...)
00242 #ifdef __GNUC__
00243     __attribute__((format (printf, 1, 2)))
00244 #endif
00245     ;
00246 
00247 #endif  /* IRPLIB_ERROR_H */
00248 

Generated on Wed Jan 17 08:33:41 2007 for SINFONI Pipeline Reference Manual by  doxygen 1.4.4