Commit 5b317b8e authored by thomas.forbriger's avatar thomas.forbriger

libdatrwxx [WP]: improve error messages in consistency checks

Let the library output a messages which should be meaningful for an end-user
of a program which uses libdatrwxx.
parent 0c05383f
......@@ -39,11 +39,13 @@
* frames is guessed
* - 08/07/2016 V1.3 thof:
* - make correct use of new DATRW_nonfatal_assert
* - 11/07/2016 V1.4 thof:
* - improve error messages in consistency checks
*
* ============================================================================
*/
#define DATRW_MSEEDREAD_MSEEDRECORD_READ_CC_VERSION \
"DATRW_MSEEDREAD_MSEEDRECORD_READ_CC V1.3"
"DATRW_MSEEDREAD_MSEEDRECORD_READ_CC V1.4"
#include <string>
#include <cstring>
......@@ -51,6 +53,8 @@
#include <datrwxx/mseedread.h>
#include <datrwxx/mseed.h>
#include <datrwxx/bytesex.h>
#include <datrwxx/debug.h>
#include <datrwxx/mseed_keywords.h>
#include <aff/subarray.h>
namespace datrw {
......@@ -229,6 +233,16 @@ namespace datrw {
* Check for data integrity, consistency, plausibility,...
*/
/* string constant containing hint to format modifiers
* (this is a very local constant, defined here becausing being used
* three times)
*/
const std::string CHintToFormatModifiers(
"consider to use format modifiers \""
+ std::string(key::nonfatal) + "\" or \""
+ std::string(key::skipcheck) + "\"\n"
"if you like to ignore this inconsistency");
/* Check for consistent number of samples.
* ---------------------------------------
*
......@@ -241,10 +255,13 @@ namespace datrw {
DATRW_nonfatal_assert(Mdebug.inconsistencies_are_not_fatal
|| (!Mchecks.nsamples.fatal),
(isample==nsamples),
"ERROR (reading MiniSEED record): "
"missing samples\n"
"isample=" << isample << " nsamples=" <<
nsamples);
"number of samples in MiniSEED record is inconsistent\n"
"consistency check \"" << key::nsamples << "\" complains:\n"
"number of samples announced in header: "
<< DATRW_value(nsamples) << "\n"
"number of samples actually used: "
<< DATRW_value(isample) << "\n"
<< CHintToFormatModifiers);
}
/* Check for consistent data values.
......@@ -267,11 +284,15 @@ namespace datrw {
DATRW_nonfatal_assert(Mdebug.inconsistencies_are_not_fatal
|| (!Mchecks.data.fatal),
(Mdata(isample-1)==xn),
"ERROR (reading MiniSEED record): "
"data is corrupt\n"
"Mdata(isample-1)=" << Mdata(isample-1)
<< " xn=" << xn
<< " isample=" << isample);
"data in MiniSEED record are inconsistent\n"
"consistency check \"" << key::data << "\" complains:\n"
"expected value of last sample "
"(i.e. reverse integration constant): "
<< DATRW_value(xn) << "\n"
"value of last sample ("
<< DATRW_value(isample) << ") actually read: "
<< DATRW_value(Mdata(isample-1)) << "\n"
<< CHintToFormatModifiers);
}
/* Check for consistent number of frames.
......@@ -290,11 +311,13 @@ namespace datrw {
DATRW_nonfatal_assert(Mdebug.inconsistencies_are_not_fatal
|| (!Mchecks.nframes.fatal),
(iframe==nframes),
"ERROR (reading MiniSEED record): "
"inconsistent frame count\n"
"number of frames (" << iframe << ") " <<
"differs from expected number ("
<< nframes << ")");
"number of frames in MiniSEED record is inconsistent\n"
"consistency check \"" << key::nframes << "\" complains:\n"
"number of frames announced in header: "
<< DATRW_value(nframes) << "\n"
"number of frames actually used: "
<< DATRW_value(iframe) << "\n"
<< CHintToFormatModifiers);
}
// finished successfully
......
Markdown is supported
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