CARMA C++
ErrHandler.h
Go to the documentation of this file.
1 // $Id: ErrHandler.h,v 1.1 2010/12/13 21:06:30 eml Exp $
2 
3 #ifndef SZA_UTIL_ERRHANDLER_H
4 #define SZA_UTIL_ERRHANDLER_H
5 
15 #include <sstream>
16 
17 #define ERR_HANDLER_FN(fn) \
18  void (fn)(std::ostringstream& os, const char* fileName, const int lineNumber, const char* functionName, bool isErr, bool isSimple, bool isSysErr)
19 
20 namespace sza {
21  namespace util {
22 
23  class ErrHandler {
24  public:
25 
29  ErrHandler();
30 
34  virtual ~ErrHandler();
35 
36  static ERR_HANDLER_FN(defaultThrowFn);
37  static ERR_HANDLER_FN(defaultReportFn);
38  static ERR_HANDLER_FN(defaultLogFn);
39 
40  // Install user-defined error handling functions
41 
42  static void installThrowFn(ERR_HANDLER_FN(*throwFn));
43  static void installReportFn(ERR_HANDLER_FN(*reportFn));
44  static void installLogFn(ERR_HANDLER_FN(*logFn));
45 
46  static ERR_HANDLER_FN(throwError);
47  static ERR_HANDLER_FN(report);
48  static ERR_HANDLER_FN(log);
49 
50  private:
51 
52  static ERR_HANDLER_FN(*throwFn_);
53  static ERR_HANDLER_FN(*reportFn_);
54  static ERR_HANDLER_FN(*logFn_);
55 
56  }; // End class ErrHandler
57 
58  } // End namespace util
59 } // End namespace sza
60 
61 
62 
63 #endif // End #ifndef SZA_UTIL_ERRHANDLER_H