errorHandling.c

00001 /******************************************************************************
00002 *******************************************************************************
00003 *                European Southern Observatory
00004 *                VLTI Data Reduction Software
00005 *
00006 * File name:    errorHandling.c
00007 * Description:    Contains the routines for systematic error and warning reports
00008 *
00009 * History:        
00010 * 22-Jul-03        (csabet) Created 
00011 *******************************************************************************
00012 ******************************************************************************/
00013 
00014 /******************************************************************************
00015 *    Compiler directives
00016 ******************************************************************************/
00017 
00018 /******************************************************************************
00019 *    Include files
00020 ******************************************************************************/
00021 #include <stdio.h>
00022 #include <cpl.h>
00023 #include <stdlib.h>
00024 #include "midiGlobal.h"
00025 #include "errorHandling.h"
00026 #include "midiLib.h"
00027 
00028 /******************************************************************************
00029 *    Global Variables
00030 ******************************************************************************/
00031 
00032 /******************************************************************************
00033 *    Prototypes
00034 ******************************************************************************/
00035 
00036 /*============================ C O D E    A R E A ===========================*/
00037 
00038 
00039 
00040 /******************************************************************************
00041 *               European Southern Observatory
00042 *             VLTI MIDI Data Reduction Software
00043 *
00044 * Module name:  midiReportTbd
00045 * Input/Output: See function arguments to avoid duplication
00046 * Description:  Diagnostic report
00047 *
00048 * History:
00049 * 17-Jun-05     (csabet)
00050 ******************************************************************************/
00051 void midiReportTbd (
00052     FILE        *filePtr,
00053     const char  routineName[],
00054     const char        *fileName,
00055     int            lineNumber,
00056     const char        *message)
00057 {
00058     
00059    cpl_msg_info(cpl_func,"\n<<TBD>>: %s \n", message);
00060    cpl_msg_info(cpl_func,"         Routine Name: %s \n", routineName);
00061    cpl_msg_info(cpl_func,"         File Name:    %s \n", fileName);
00062    cpl_msg_info(cpl_func,"         Line Number:  %d \n\n", lineNumber);
00063 
00064     fprintf (filePtr, "\n<<TBD>>: %s \n", message);
00065     fprintf (filePtr, "         Routine Name: %s \n", routineName);
00066     fprintf (filePtr, "         File Name:    %s \n", fileName);
00067     fprintf (filePtr, "         Line Number:  %d \n\n", lineNumber);
00068 
00069     return;
00070 }
00071 /*****************************************************************************/
00072 
00073 
00074 /******************************************************************************
00075 *                European Southern Observatory
00076 *              VLTI MIDI Data Reduction Software
00077 *
00078 * Module name:    midiReportError
00079 * Input/Output:    See function arguments to avoid duplication
00080 * Description:    Exception Handling
00081 *
00082 * History:        
00083 * 03-Sep-03        (csabet)
00084 ******************************************************************************/
00085 void midiReportError(
00086     FILE        *filePtr,
00087     const char  routineName[],
00088     const char        *fileName,
00089     int            lineNumber,
00090     const char        *message)
00091 {
00092    
00093    cpl_msg_info(cpl_func,"\n<<ERROR>>: %s \n", message);
00094    cpl_msg_info(cpl_func,"           Routine Name: %s \n", routineName);
00095    cpl_msg_info(cpl_func,"           File Name:    %s \n", fileName);
00096    cpl_msg_info(cpl_func,"           Line Number:  %d \n\n", lineNumber);
00097 
00098     fprintf (filePtr, "\n<<ERROR>>: %s \n", message);
00099     fprintf (filePtr, "           Routine Name: %s \n", routineName);
00100     fprintf (filePtr, "           File Name:    %s \n", fileName);
00101     fprintf (filePtr, "           Line Number:  %d \n\n", lineNumber);
00102     
00103     fclose (filePtr);
00104     exit (2);    
00105 }
00106 /*****************************************************************************/
00107 
00108 
00109 
00110 /******************************************************************************
00111 *                European Southern Observatory
00112 *              VLTI MIDI Data Reduction Software
00113 *
00114 * Module name:    midiReportInfo
00115 * Input/Output:    See function arguments to avoid duplication
00116 * Description:    Exception Handling for Information
00117 *
00118 * History:        
00119 * 18-Nov-03        (csabet)
00120 ******************************************************************************/
00121 void midiReportInfo(
00122     FILE        *filePtr,
00123     const char  routineName[],
00124     const char        *fileName,
00125     int            lineNumber,
00126     const char        *message)
00127 {
00128 
00129     if (diagnostic > 4)
00130     {
00131        cpl_msg_info(cpl_func,"\n%s \n", message);
00132        cpl_msg_info(cpl_func,"Routine Name: %s \n", routineName);
00133        cpl_msg_info(cpl_func,"File Name:    %s \n", fileName);
00134        cpl_msg_info(cpl_func,"Line Number:  %d \n", lineNumber);
00135 
00136         fprintf (filePtr, "\n%s \n", message);
00137         fprintf (filePtr, "Routine Name: %s \n", routineName);
00138         fprintf (filePtr, "File Name:    %s \n", fileName);
00139         fprintf (filePtr, "Line Number:  %d \n", lineNumber);
00140     }
00141     else
00142     {
00143        cpl_msg_info(cpl_func,"%s \n", message);
00144         fprintf (filePtr, "%s \n", message);
00145     }
00146 
00147     return;
00148 }
00149 /*****************************************************************************/
00150 
00151 
00152 /******************************************************************************
00153 *                European Southern Observatory
00154 *              VLTI MIDI Data Reduction Software
00155 *
00156 * Module name:    midiReportError
00157 * Input/Output:    See function arguments to avoid duplication
00158 * Description:    Exception Handling for warnings
00159 *
00160 * History:        
00161 * 18-Nov-03        (csabet)
00162 ******************************************************************************/
00163 void midiReportWarning(
00164     FILE        *filePtr,
00165     const char  routineName[],
00166     const char        *fileName,
00167     int            lineNumber,
00168     const char        *message)
00169 {
00170    
00171     if (diagnostic > 4)
00172     {
00173        cpl_msg_info(cpl_func,"\n<<WARNING>>: %s \n", message);
00174        cpl_msg_info(cpl_func,"             Routine Name: %s \n", routineName);
00175        cpl_msg_info(cpl_func,"             File Name:    %s \n", fileName);
00176        cpl_msg_info(cpl_func,"             Line Number:  %d \n\n", lineNumber);
00177 
00178         fprintf (filePtr, "\n<<WARNING>>: %s \n", message);
00179         fprintf (filePtr, "             Routine Name:  %s \n", routineName);
00180         fprintf (filePtr, "             File Name:     %s \n", fileName);
00181         fprintf (filePtr, "             Line Number:   %d \n\n", lineNumber);
00182     }
00183     else
00184     {
00185        cpl_msg_info(cpl_func,"<<WARNING>>: %s \n", message);
00186         fprintf (filePtr, "<<WARNING>>: %s \n", message);
00187     }
00188     
00189     return;
00190 }
00191 /*****************************************************************************/
00192 
00193 
00194 /******************************************************************************
00195 *               European Southern Observatory
00196 *            VLTI MIDI Data Reduction Software
00197 *
00198 * Module name:  Trace
00199 * Input/Output: See function arguments to avoid duplication
00200 * Description:    
00201 *
00202 * History:
00203 * 21-Jul-03     (JM)
00204 * 20-Jan-05        (csabet) Integrated
00205 ******************************************************************************/
00206 void Trace (
00207     int    n)
00208 {
00209    if (!diagnostic) return;
00210   cpl_msg_info(cpl_func,"\nTrace %d", n);
00211   cpl_msg_info(cpl_func,"\n");
00212 }
00213 /*****************************************************************************/
00214 
00215 
00216 
00217 /******************************************************************************
00218 *                European Southern Observatory
00219 *              VLTI MIDI Data Reduction Software
00220 *
00221 * Module name:    abortIfError
00222 * Input/Output:    See function arguments to avoid duplication
00223 * Description:    Exception Handling
00224 *
00225 * History:        
00226 * 24-Feb-03        (jmeisner)    Leiden. Created
00227 * 03-Mar-03        (csabet)     Revised
00228 ******************************************************************************/
00229 void abortIfError(
00230     int        errcode, 
00231     char    *message)
00232 {
00233     if(!errcode) return;
00234    cpl_msg_info(cpl_func,"\n\n <<ERROR>: %s, code %d.\n\n", message, errcode);
00235     exit(errcode);
00236 }
00237 /*****************************************************************************/

Generated on 15 Mar 2012 for MIDI Pipeline Reference Manual by  doxygen 1.6.1