summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/devreader-linux.cpp4
-rw-r--r--src/main.cpp15
2 files changed, 16 insertions, 3 deletions
diff --git a/src/devreader-linux.cpp b/src/devreader-linux.cpp
index 5b6e9eb..85824cd 100644
--- a/src/devreader-linux.cpp
+++ b/src/devreader-linux.cpp
@@ -14,6 +14,8 @@
#include <string>
#include <list>
+#include <stdexcept>
+
using namespace std;
bool DevReaderLinux::isAvailable()
@@ -28,6 +30,6 @@ list<string> DevReaderLinux::findAllDevices()
else if(DevReaderLinuxProc::isAvailable())
return DevReaderLinuxProc::findAllDevices();
else
- return list<string>();
+ throw std::runtime_error("neither sysfs nor proc is available");
}
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