DATRW++ library: seismic data I/O with multiple formats

◆ report_violation()

void datrw::util::report_violation ( const Ereport t,
const std::string &  message,
const std::string &  file,
const int &  line,
const std::string &  condition 
)

report violation of assertion

report violation of condition

Parameters
messagemessage of type char*
filename of source code file
linesource code line number
conditionassert condition
ttype of incident to be reported

Definition at line 52 of file report.cc.

References Ffatal, Fnonfatal, Fwarning, and datrw::libversion.

Referenced by datrw::Exception::base_report().

57  {
58  if (t==Fnonfatal)
59  {
60  cerr << "ERROR (non-fatal)";
61  }
62  else if (t==Fwarning)
63  {
64  cerr << "WARNING";
65  }
66  else
67  {
68  cerr << "ERROR";
69  }
70 
71  cerr << " reported by " << datrw::libversion << "!" << endl;
72  cerr << "| A problem occured while "
73  "reading or writing time series data" << endl;
74  if (!condition.empty())
75  {
76  cerr << "| the following condition is violated:" << endl
77  << "| \"" << condition << "\"" << endl;
78  }
79  if (!file.empty())
80  {
81  cerr << "| in \"" << file << "\" at line #" << line << endl;
82  }
83  if (message.empty())
84  {
85  cerr << "| no further comment is provided." << endl;
86  }
87  else
88  {
89  const std::string delimiter("\n");
90  std::string::size_type posend=0, pos=0;
91  std::string::size_type len=0;
92  while (posend!=std::string::npos)
93  {
94  posend=message.find(delimiter, pos);
95  len=posend-pos;
96  cerr << "* ";
97  cerr << message.substr(pos, len) << endl;
98  if (posend!=std::string::npos) { len+=delimiter.length(); }
99  pos+=len;
100  } // while (posend!=std::string::npos)
101  } // if (message.empty())
102  if (t==Ffatal)
103  {
104  cerr << "This error is fatal. The program probably will abort..."
105  << endl;
106  }
107  cerr.flush();
108  } // void report_violation(...)
a fatal error; processing wil abort as a consequence
Definition: report.h:58
just a warning; processing can proceeed
Definition: report.h:54
const char *const libversion
Version string.
Definition: aalibdatrwxx.cc:18
an error, but non-fatal; processing will proceed
Definition: report.h:56
Here is the caller graph for this function: