]> git.tdb.fi Git - libs/gui.git/commitdiff
Add a dedicated exception class for unavailable input devices
authorMikko Rasa <tdb@tdb.fi>
Fri, 19 Dec 2014 12:05:47 +0000 (14:05 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 19 Dec 2014 12:05:47 +0000 (14:05 +0200)
source/input/device.h
source/input/generic/gamecontroller.cpp
source/input/touchscreen.cpp

index 7df388b18c34f5f0d2dc1001ac61e27ae5b9afa8..b42ed3fde4991feb8d87b05258831585db57efec 100644 (file)
@@ -3,11 +3,20 @@
 
 #include <string>
 #include <vector>
+#include <stdexcept>
 #include <sigc++/signal.h>
 
 namespace Msp {
 namespace Input {
 
+class device_not_available: public std::runtime_error
+{
+public:
+       device_not_available(const std::string &w): std::runtime_error(w) { }
+       virtual ~device_not_available() throw() { }
+};
+
+
 /**
 Base class for input devices.  Input devices have two types of controls:
 buttons and axes.  Buttons are either on or off.  Axes have a floating point
index b320342c732cc1adc5b071781bdcebf659eb5ca0..9ba7130eb925097a7003711d364358ae3c44bf53 100644 (file)
@@ -8,7 +8,7 @@ namespace Input {
 
 GameController::GameController(unsigned)
 {
-       throw runtime_error("not supported");
+       throw device_not_available("GameController");
 }
 
 GameController::~GameController()
index 4facb8c60e44f9b662c636a225946923245497dc..c4de688a76d32efddcf3905f7a4bdeded22e204b 100644 (file)
@@ -9,7 +9,7 @@ Touchscreen::Touchscreen(Graphics::Window &w):
        window(w)
 {
        if(!is_available())
-               throw runtime_error("touchscreen not available");
+               throw device_not_available("Touchscreen");
 
        name = "Touchscreen";