casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FITSError.h
Go to the documentation of this file.
1 //# FITSError.h: default FITS error handling function, typdef, and enumeration
2 //# Copyright (C) 1999
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //#
27 //# $Id$
28 
29 #ifndef FITS_FITSERROR_H
30 #define FITS_FITSERROR_H
31 
32 //#! Includes go here
33 #include <casacore/casa/aips.h>
34 
35 namespace casacore { //# NAMESPACE CASACORE - BEGIN
36 
37 // <summary>
38 // default FITS error handling function, typdef, and enumeration
39 // </summary>
40 
41 // <use visibility=export>
42 
43 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
44 // </reviewed>
45 
46 // <synopsis>
47 // FITSError contains the enumeration specifying the possible error
48 // message levels. It also contains the default error handling function
49 // for the FITS classes.
50 // </synopsis>
51 //
52 // <example>
53 // This example shows how one could set up an error handler
54 // which does what the FITS classes originally did - just
55 // send the error message to cout without any indication as
56 // to the severity of the error message.
57 // <srcblock>
58 // void coutErrHandler(const char *errMessage, FITSError::ErrorLevel)
59 // { cout << errMessage << endl; }
60 //
61 // FitsInput fin("myFile", FITS::Disk, 10, coutErrHandler);
62 // </srcblock>
63 // Any error messages generated by fin will be sent to cout.
64 // Error handlers for the HDUs would need to be indicated in
65 // their constructors. For example:
66 // <srcblock>
67 // PrimaryArray<Float> pa(fin, coutErrHandler);
68 // </srcblock>
69 // The default error handler is FITSError::defaultHandler which
70 // sends the error message to the global log sink at the
71 // severity implied by ErrorLevel.
72 //
73 // The error handler only handles the error messages. It is up to
74 // the programmer to check for the error status of classes like
75 // FitsInput.
76 // </example>
77 //
78 // <motivation>
79 // Originally, FITS error message were simply sent to an ostream. In
80 // order to have these error messages go to the Casacore logger by default,
81 // this class was added. This was made a separate class because both
82 // BlockIo and FITS need to use this class. The anticipated replacements
83 // for the current FITS classes use a somewhat similar scheme.
84 // </motivation>
85 
86 class FITSError
87 {
88 public:
89 
90  // WARN means that the FITS file is still usable - this generally
91  // happens when parsing the HDU and some minor, recoverable
92  // violation of the FITS rules is detected.
93  // SEVERE means that a fatal error has occurred and the FITS file
94  // can not be properly processed.
95  enum ErrorLevel { INFO, WARN, SEVERE };
96 
97  // The default error handler. The errMessage is posted to
98  // the global log sink at the severity implied by ErrorLevel.
99  // It is assumed that errMessage is null terminated.
100  static void defaultHandler(const char *errMessage, ErrorLevel severity);
101 };
102 
103 // <summary>
104 // Define a typedef for the handler function signature for convenience.
105 // </summary>
106 
107 // <use visibility=export>
108 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
109 // </reviewed>
110 
111 typedef void (*FITSErrorHandler) (const char* errMessage,
112  FITSError::ErrorLevel severity);
113 
114 
115 
116 } //# NAMESPACE CASACORE - END
117 
118 #endif
119 
120 
void(* FITSErrorHandler)(const char *errMessage, FITSError::ErrorLevel severity)
Define a typedef for the handler function signature for convenience.
Definition: FITSError.h:111
default FITS error handling function, typdef, and enumeration
Definition: FITSError.h:86
ErrorLevel
WARN means that the FITS file is still usable - this generally happens when parsing the HDU and some ...
Definition: FITSError.h:95
static void defaultHandler(const char *errMessage, ErrorLevel severity)
The default error handler.