diff options
author | Olivier Gayot <duskcoder@gmail.com> | 2014-06-18 16:09:09 +0200 |
---|---|---|
committer | Olivier Gayot <duskcoder@gmail.com> | 2014-06-18 16:48:12 +0200 |
commit | f3c4b3ef578830679e312ce2efb706499db0b1c3 (patch) | |
tree | 581eb014e11fc3b1f02b6e4afd3a8333e29c113b /src/main.cpp | |
parent | 0e03940802cebefdf6b0597a154bd9395e1af4d2 (diff) |
The program used to return an empty list of devices.
Nevertheless, the method printTraffic of TrafficWindow does not handle
empty lists.
Fixed by throwing an exception whenever proc and sysfs are both
unaccessible.
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp index c53e142..5b32183 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -48,6 +48,8 @@ #include <string> #include <vector> +#include <stdexcept> + #include <ctype.h> #include <time.h> #include <curses.h> @@ -352,8 +354,17 @@ int main(int argc, char *argv[]) } } - // auto-detect network devices - DevReaderFactory::findAllDevices(); + try + { + // auto-detect network devices + DevReaderFactory::findAllDevices(); + } + catch (std::runtime_error e) + { + cerr << "Cannot find any device: " << e.what() << endl; + return -1; + }; + const map<string, DevReader*>& deviceReaders = DevReaderFactory::getAllDevReaders(); // create one instance of the Device class per device |