summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-02-27 14:16:58 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-02-27 14:16:58 +0100
commit1e2a6c6e367849335fd82efb4afc827fd4fe82a6 (patch)
tree19d07a64c8bc3ccbba131ff2385fc4ec93660b14 /src
parentb11eff2c8c913d470897e5395b240939ed46dc35 (diff)
downloaddabmod-1e2a6c6e367849335fd82efb4afc827fd4fe82a6.tar.gz
dabmod-1e2a6c6e367849335fd82efb4afc827fd4fe82a6.tar.bz2
dabmod-1e2a6c6e367849335fd82efb4afc827fd4fe82a6.zip
Create custom exception for ZMQ overflow
Diffstat (limited to 'src')
-rw-r--r--src/DabMod.cpp18
-rw-r--r--src/InputReader.h8
-rw-r--r--src/InputZeroMQReader.cpp2
3 files changed, 18 insertions, 10 deletions
diff --git a/src/DabMod.cpp b/src/DabMod.cpp
index 2489797..6cf1b96 100644
--- a/src/DabMod.cpp
+++ b/src/DabMod.cpp
@@ -107,7 +107,7 @@ enum run_modulator_state {
MOD_AGAIN
};
-run_modulator_state run_modulator(modulator_data& m);
+run_modulator_state run_modulator(Logger& logger, modulator_data& m);
int main(int argc, char* argv[])
{
@@ -776,7 +776,7 @@ int main(int argc, char* argv[])
m.inputReader->PrintInfo();
- run_modulator_state st = run_modulator(m);
+ run_modulator_state st = run_modulator(logger, m);
switch (st) {
case MOD_FAILURE:
@@ -824,7 +824,7 @@ int main(int argc, char* argv[])
return ret;
}
-run_modulator_state run_modulator(modulator_data& m)
+run_modulator_state run_modulator(Logger& logger, modulator_data& m)
{
run_modulator_state ret = MOD_FAILURE;
try {
@@ -858,24 +858,24 @@ run_modulator_state run_modulator(modulator_data& m)
}
}
if (framesize == 0) {
- fprintf(stderr, "End of file reached.\n");
+ logger.level(info) << "End of file reached.";
}
else {
- fprintf(stderr, "Input read error.\n");
+ logger.level(error) << "Input read error.";
}
running = 0;
ret = MOD_NORMAL_END;
}
} catch (fct_discontinuity_error& e) {
// The OutputUHD saw a FCT discontinuity
- fprintf(stderr, "Stream discontinuity\n");
+ logger.level(warn) << e.what();
ret = MOD_AGAIN;
- } catch (std::overflow_error& e) {
+ } catch (zmq_input_overflow& e) {
// The ZeroMQ input has overflowed its buffer
- fprintf(stderr, "overflow error: %s\n", e.what());
+ logger.level(warn) << e.what();
ret = MOD_AGAIN;
} catch (std::exception& e) {
- fprintf(stderr, "EXCEPTION: %s\n", e.what());
+ logger.level(error) << "Exception caught: " << e.what();
ret = MOD_FAILURE;
}
diff --git a/src/InputReader.h b/src/InputReader.h
index e45e36d..dcf88cc 100644
--- a/src/InputReader.h
+++ b/src/InputReader.h
@@ -130,6 +130,14 @@ class InputFileReader : public InputReader
// after 2**32 * 24ms ~= 3.3 years
};
+struct zmq_input_overflow : public std::exception
+{
+ const char* what () const throw ()
+ {
+ return "InputZMQ buffer overflow";
+ }
+};
+
#if defined(HAVE_ZEROMQ)
/* A ZeroMQ input. See www.zeromq.org for more info */
diff --git a/src/InputZeroMQReader.cpp b/src/InputZeroMQReader.cpp
index 7ac7d41..51909c2 100644
--- a/src/InputZeroMQReader.cpp
+++ b/src/InputZeroMQReader.cpp
@@ -88,7 +88,7 @@ int InputZeroMQReader::GetNextFrame(void* buffer)
in_messages_.wait_and_pop(incoming);
if (! workerdata_.running) {
- throw std::overflow_error("InputZeroMQ worker dead");
+ throw zmq_input_overflow();
}
memcpy(buffer, incoming, framesize);