sinfo_error.h

00001 /*
00002  * This file is part of the ESO SINFONI Pipeline
00003  * Copyright (C) 2004,2005 European Southern Observatory
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, 51 Franklin St, Fifth Floor, Boston, MA  02111-1307  USA
00018  */
00019 
00020 /*
00021  * $Author: amodigli $
00022  * $Date: 2007/10/26 09:42:36 $
00023  * $Revision: 1.13 $
00024  * $Name: sinfo-2_2_5 $
00025  * $Log: sinfo_error.h,v $
00026  * Revision 1.13  2007/10/26 09:42:36  amodigli
00027  * removed check on CPL_VERSION_CODE (now works only for CPL4)
00028  *
00029  * Revision 1.12  2007/08/14 10:01:41  amodigli
00030  * added sinfo_stop_if_error
00031  *
00032  * Revision 1.11  2007/08/11 10:46:18  amodigli
00033  * clean
00034  *
00035  * Revision 1.9  2007/08/08 11:17:26  amodigli
00036  * change to support CPL31 & CPL40
00037  *
00038  * Revision 1.8  2007/06/06 07:10:45  amodigli
00039  * replaced tab with 4 spaces
00040  *
00041  * Revision 1.7  2006/11/21 11:56:10  amodigli
00042  * replaced __func__ by cpl_func
00043  *
00044  * Revision 1.6  2006/10/16 07:26:23  amodigli
00045  * shortened line length
00046  *
00047  * Revision 1.5  2006/10/13 08:09:42  amodigli
00048  * shorten line length
00049  *
00050  * Revision 1.4  2006/10/13 06:34:40  amodigli
00051  * shorten line length
00052  *
00053  * Revision 1.3  2006/10/04 06:17:45  amodigli
00054  * added doxygen doc
00055  *
00056  * Revision 1.2  2006/07/31 06:33:34  amodigli
00057  * fixed  bug in ck0 macro
00058  *
00059  * Revision 1.1  2006/05/30 09:09:37  amodigli
00060  * added to repository
00061  *
00062  *
00063  */
00064 
00065 #ifndef SINFO_ERROR_H
00066 #define SINFO_ERROR_H
00067 
00072 /*-----------------------------------------------------------------------------
00073                     Includes
00074 -----------------------------------------------------------------------------*/
00075 #include <cpl_error.h>
00076 #include <cpl.h>
00077 
00078 #include <irplib_utils.h>
00079 /*-----------------------------------------------------------------------------
00080                              Defines
00081 -----------------------------------------------------------------------------*/
00082 /* To save some key-strokes, use the irplib error handling macros
00083    under different (shorter) names.
00084    Additionally, irplib macros require the VA_ARGS to be enclosed in (),
00085 */
00086 
00087 #define assure(BOOL, CODE, ...) \
00088   cpl_error_ensure(BOOL, CODE, goto cleanup,__VA_ARGS__)
00089 
00090 #define assure_nomsg(BOOL, CODE, ...)               \
00091   cpl_error_ensure(BOOL, CODE, goto cleanup,__VA_ARGS__)
00092 
00093 #define sinfo_stop_if_error() \
00094      do if(cpl_error_get_code()) { \
00095      cpl_msg_error(__func__,"Traced error"); \
00096      irplib_trace(); \
00097      goto cleanup; \
00098      } while (0) 
00099 
00100 #define ck0(IEXP, ...) \
00101   cpl_error_ensure(IEXP == 0, CPL_ERROR_UNSPECIFIED, \
00102    goto cleanup,__VA_ARGS__)
00103 
00104 #define ck0_nomsg(IEXP) ck0(IEXP," ")
00105 
00106 #define cknull(NULLEXP, ...) \
00107   cpl_error_ensure((NULLEXP) != NULL, \
00108   CPL_ERROR_UNSPECIFIED, goto cleanup,__VA_ARGS__)
00109 
00110 #define cknull_nomsg(NULLEXP) cknull(NULLEXP," ")
00111 
00112 #define  check(CMD, ...)                                                 \
00113   cpl_error_ensure((sinfo_msg_softer(), (CMD), sinfo_msg_louder(),      \
00114               cpl_error_get_code() == CPL_ERROR_NONE),       \
00115                        cpl_error_get_code(), goto cleanup,__VA_ARGS__)
00116 
00117 #define  check_nomsg(CMD) check(CMD, " ")
00118 
00119 #define passure(BOOL, ...)                                               \
00120   cpl_error_ensure(BOOL, CPL_ERROR_UNSPECIFIED, goto cleanup,\
00121                       ("Internal error. Please report to "                \
00122                       PACKAGE_BUGREPORT " " __VA_ARGS__))
00123                        //  Assumes that PACKAGE_BUGREPORT
00124                //contains no formatting special characters  
00125    
00126 
00410 #endif

Generated on 8 Mar 2011 for SINFONI Pipeline Reference Manual by  doxygen 1.6.1