File: FitsError.cxx

package info (click to toggle)
ccfits 2.4-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 11,992 kB
  • sloc: cpp: 14,287; sh: 10,811; makefile: 165; perl: 94
file content (77 lines) | stat: -rw-r--r-- 1,650 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//	Astrophysics Science Division,
//	NASA/ Goddard Space Flight Center
//	HEASARC
//	http://heasarc.gsfc.nasa.gov
//	e-mail: ccfits@legacy.gsfc.nasa.gov
//
//	Original author: Ben Dorman
#ifdef _MSC_VER
#include "MSconfig.h" // for truncation warning
#include <cassert>
#endif

// FITS
#include "FITS.h"
// FitsError
#include "FitsError.h"


namespace CCfits {

  // Class CCfits::FitsError 

  FitsError::FitsError (int errornum, bool silent)
  : FitsException("FITS Error: ", silent)
  {
     printMsg(errornum);
     if (FITS::verboseMode() || !silent) 
        std::cerr << message() << "\n";
  }


  void FitsError::printMsg (int error)
  {
     char cMessage[FLEN_ERRMSG];

     fits_get_errstatus(error, cMessage);
     addToMessage(string(cMessage));
  }

  // Class CCfits::FitsException 

  FitsException::FitsException (const string& msg, bool& silent)
    : m_message(msg)
  {
  if (FITS::verboseMode() || !silent) 
  {
          std::cerr << '\n' << msg;
          // set this to false for the purpose of this exception.
          // does NOT change verbose mode setting so this value is thrown
          // away after the exception completes.
          silent = false;
  }
  }


  void FitsException::addToMessage (const string& msgQual)
  {
     m_message += msgQual;
  }

  // Class CCfits::FitsFatal 

  FitsFatal::FitsFatal (const string& diag)
  {
     std::cerr << "*** CCfits Fatal Error: " << diag 
               << " please report this to xanprob@olegacy.gsfc.nasa.gov\n";

#ifdef TERMINATE_DEFECT
     // terminate() is not there as documented
	 assert ( false );
#else
	 std::terminate();
#endif
  }


} // namespace CCfits