MIDI Pipeline Reference Manual  2.8.3
errorHandling.c
1 /******************************************************************************
2 *******************************************************************************
3 * European Southern Observatory
4 * VLTI Data Reduction Software
5 *
6 * File name: errorHandling.c
7 * Description: Contains the routines for systematic error and warning reports
8 *
9 * History:
10 * 22-Jul-03 (csabet) Created
11 *******************************************************************************
12 ******************************************************************************/
13 
14 /******************************************************************************
15 * Compiler directives
16 ******************************************************************************/
17 
18 /******************************************************************************
19 * Include files
20 ******************************************************************************/
21 #include <stdio.h>
22 #include <cpl.h>
23 #include <stdlib.h>
24 #include "midiGlobal.h"
25 #include "errorHandling.h"
26 #include "midiLib.h"
27 
28 /******************************************************************************
29 * Global Variables
30 ******************************************************************************/
31 
32 /******************************************************************************
33 * Prototypes
34 ******************************************************************************/
35 
36 /*============================ C O D E A R E A ===========================*/
37 
38 
39 
40 /******************************************************************************
41 * European Southern Observatory
42 * VLTI MIDI Data Reduction Software
43 *
44 * Module name: midiReportTbd
45 * Input/Output: See function arguments to avoid duplication
46 * Description: Diagnostic report
47 *
48 * History:
49 * 17-Jun-05 (csabet)
50 ******************************************************************************/
51 void midiReportTbd (
52  FILE *filePtr,
53  const char routineName[],
54  const char *fileName,
55  int lineNumber,
56  const char *message)
57 {
58 
59  cpl_msg_info(cpl_func,"\n<<TBD>>: %s \n", message);
60  cpl_msg_info(cpl_func," Routine Name: %s \n", routineName);
61  cpl_msg_info(cpl_func," File Name: %s \n", fileName);
62  cpl_msg_info(cpl_func," Line Number: %d \n\n", lineNumber);
63 
64  fprintf (filePtr, "\n<<TBD>>: %s \n", message);
65  fprintf (filePtr, " Routine Name: %s \n", routineName);
66  fprintf (filePtr, " File Name: %s \n", fileName);
67  fprintf (filePtr, " Line Number: %d \n\n", lineNumber);
68 
69  return;
70 }
71 /*****************************************************************************/
72 
73 
74 /******************************************************************************
75 * European Southern Observatory
76 * VLTI MIDI Data Reduction Software
77 *
78 * Module name: midiReportError
79 * Input/Output: See function arguments to avoid duplication
80 * Description: Exception Handling
81 *
82 * History:
83 * 03-Sep-03 (csabet)
84 ******************************************************************************/
85 void midiReportError(
86  FILE *filePtr,
87  const char routineName[],
88  const char *fileName,
89  int lineNumber,
90  const char *message)
91 {
92 
93  cpl_msg_info(cpl_func,"\n<<ERROR>>: %s \n", message);
94  cpl_msg_info(cpl_func," Routine Name: %s \n", routineName);
95  cpl_msg_info(cpl_func," File Name: %s \n", fileName);
96  cpl_msg_info(cpl_func," Line Number: %d \n\n", lineNumber);
97 
98  fprintf (filePtr, "\n<<ERROR>>: %s \n", message);
99  fprintf (filePtr, " Routine Name: %s \n", routineName);
100  fprintf (filePtr, " File Name: %s \n", fileName);
101  fprintf (filePtr, " Line Number: %d \n\n", lineNumber);
102 
103  fclose (filePtr);
104  exit (2);
105 }
106 /*****************************************************************************/
107 
108 
109 
110 /******************************************************************************
111 * European Southern Observatory
112 * VLTI MIDI Data Reduction Software
113 *
114 * Module name: midiReportInfo
115 * Input/Output: See function arguments to avoid duplication
116 * Description: Exception Handling for Information
117 *
118 * History:
119 * 18-Nov-03 (csabet)
120 ******************************************************************************/
121 void midiReportInfo(
122  FILE *filePtr,
123  const char routineName[],
124  const char *fileName,
125  int lineNumber,
126  const char *message)
127 {
128 
129  if (diagnostic > 4)
130  {
131  cpl_msg_info(cpl_func,"\n%s \n", message);
132  cpl_msg_info(cpl_func,"Routine Name: %s \n", routineName);
133  cpl_msg_info(cpl_func,"File Name: %s \n", fileName);
134  cpl_msg_info(cpl_func,"Line Number: %d \n", lineNumber);
135 
136  fprintf (filePtr, "\n%s \n", message);
137  fprintf (filePtr, "Routine Name: %s \n", routineName);
138  fprintf (filePtr, "File Name: %s \n", fileName);
139  fprintf (filePtr, "Line Number: %d \n", lineNumber);
140  }
141  else
142  {
143  cpl_msg_info(cpl_func,"%s \n", message);
144  fprintf (filePtr, "%s \n", message);
145  }
146 
147  return;
148 }
149 /*****************************************************************************/
150 
151 
152 /******************************************************************************
153 * European Southern Observatory
154 * VLTI MIDI Data Reduction Software
155 *
156 * Module name: midiReportError
157 * Input/Output: See function arguments to avoid duplication
158 * Description: Exception Handling for warnings
159 *
160 * History:
161 * 18-Nov-03 (csabet)
162 ******************************************************************************/
163 void midiReportWarning(
164  FILE *filePtr,
165  const char routineName[],
166  const char *fileName,
167  int lineNumber,
168  const char *message)
169 {
170 
171  if (diagnostic > 4)
172  {
173  cpl_msg_info(cpl_func,"\n<<WARNING>>: %s \n", message);
174  cpl_msg_info(cpl_func," Routine Name: %s \n", routineName);
175  cpl_msg_info(cpl_func," File Name: %s \n", fileName);
176  cpl_msg_info(cpl_func," Line Number: %d \n\n", lineNumber);
177 
178  fprintf (filePtr, "\n<<WARNING>>: %s \n", message);
179  fprintf (filePtr, " Routine Name: %s \n", routineName);
180  fprintf (filePtr, " File Name: %s \n", fileName);
181  fprintf (filePtr, " Line Number: %d \n\n", lineNumber);
182  }
183  else
184  {
185  cpl_msg_info(cpl_func,"<<WARNING>>: %s \n", message);
186  fprintf (filePtr, "<<WARNING>>: %s \n", message);
187  }
188 
189  return;
190 }
191 /*****************************************************************************/
192 
193 
194 /******************************************************************************
195 * European Southern Observatory
196 * VLTI MIDI Data Reduction Software
197 *
198 * Module name: Trace
199 * Input/Output: See function arguments to avoid duplication
200 * Description:
201 *
202 * History:
203 * 21-Jul-03 (JM)
204 * 20-Jan-05 (csabet) Integrated
205 ******************************************************************************/
206 void Trace (
207  int n)
208 {
209  if (!diagnostic) return;
210  cpl_msg_info(cpl_func,"\nTrace %d", n);
211  cpl_msg_info(cpl_func,"\n");
212 }
213 /*****************************************************************************/
214 
215 
216 
217 /******************************************************************************
218 * European Southern Observatory
219 * VLTI MIDI Data Reduction Software
220 *
221 * Module name: abortIfError
222 * Input/Output: See function arguments to avoid duplication
223 * Description: Exception Handling
224 *
225 * History:
226 * 24-Feb-03 (jmeisner) Leiden. Created
227 * 03-Mar-03 (csabet) Revised
228 ******************************************************************************/
229 void abortIfError(
230  int errcode,
231  char *message)
232 {
233  if(!errcode) return;
234  cpl_msg_info(cpl_func,"\n\n <<ERROR>: %s, code %d.\n\n", message, errcode);
235  exit(errcode);
236 }
237 /*****************************************************************************/