Commit 0c5c97c4 authored by thomas.forbriger's avatar thomas.forbriger
Browse files

libdatrwxx [WP]: use common report function

Notice: the error output will be awfully scrambled, since the body of
report_violation is not yet adjusted.
parent 07b4111f
......@@ -128,7 +128,8 @@
*/
#define DATRW_report_assert(C,M,V) \
if (!(C)) { \
datrw::util::report_violation(M, __FILE__, __LINE__, #C); \
datrw::util::report_violation(datrw::util::Fnonfatal, \
M, __FILE__, __LINE__, #C); \
std::cerr << "* comment: " << V << std::endl; \
std::cerr << std::endl; \
std::cerr.flush(); \
......
......@@ -99,26 +99,11 @@ namespace datrw {
//! report
void Exception::base_report() const
{
cerr << "ERROR message from " << datrw::libversion << ":" << endl;
cerr << " A problem occured while "
"reading or writing time series data!" << endl;
if (Mmessage.empty())
{
cerr << " No message" << endl;
}
else
{
cerr << " " << Mmessage << endl;
}
if (!Mcondition.empty())
{
cerr << " Violation of condition" << endl
<< " \"" << Mcondition << "\"" << endl;
}
if (!Mfile.empty())
{
cerr << " triggered in \"" << Mfile << "\" at line #" << Mline << endl;
}
datrw::util::report_violation(datrw::util::Ffatal,
Mmessage,
Mfile,
Mline,
Mcondition);
}
} // namespace datrw
......
......@@ -49,11 +49,33 @@ namespace datrw {
namespace util {
//! report violation of assertion
void report_violation(const std::string& message,
void report_violation(const Ereport& t,
const std::string& message,
const std::string& file,
const int& line,
const std::string& condition)
{
cerr << "ERROR message from " << datrw::libversion << ":" << endl;
cerr << " A problem occured while "
"reading or writing time series data!" << endl;
if (message.empty())
{
cerr << " No message" << endl;
}
else
{
cerr << " " << message << endl;
}
if (!condition.empty())
{
cerr << " Violation of condition" << endl
<< " \"" << condition << "\"" << endl;
}
if (!file.empty())
{
cerr << " triggered in \"" << file << "\" at line #" << line << endl;
}
cerr << endl;
cerr << "ERROR: " << datrw::libversion << " ";
cerr << "reports violation of condition:" << endl;
......
......@@ -49,14 +49,14 @@ namespace datrw {
/*! \brief report categories
* \ingroup group_error
*/
enum Ereports {
enum Ereport {
//! just a warning; processing can proceeed
Fwarning,
//! an error, but non-fatal; processing will proceed
Fnonfatal,
//! a fatal error; processing wil abort as a consequence
Ferror
}; // enum Ereports
Ffatal
}; // enum Ereport
/* ---------------------------------------------------------------------- */
......@@ -67,8 +67,10 @@ namespace datrw {
* \param file name of source code file
* \param line source code line number
* \param condition assert condition
* \param t type of incident to be reported
*/
void report_violation(const std::string& message,
void report_violation(const Ereport& t,
const std::string& message,
const std::string& file,
const int& line,
const std::string& condition);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment