From: Mikko Rasa Date: Fri, 19 Dec 2014 12:05:47 +0000 (+0200) Subject: Add a dedicated exception class for unavailable input devices X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=e217a93d59aecfa80eec8bfa16b3976abdceca81;p=libs%2Fgui.git Add a dedicated exception class for unavailable input devices --- diff --git a/source/input/device.h b/source/input/device.h index 7df388b..b42ed3f 100644 --- a/source/input/device.h +++ b/source/input/device.h @@ -3,11 +3,20 @@ #include #include +#include #include 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 diff --git a/source/input/generic/gamecontroller.cpp b/source/input/generic/gamecontroller.cpp index b320342..9ba7130 100644 --- a/source/input/generic/gamecontroller.cpp +++ b/source/input/generic/gamecontroller.cpp @@ -8,7 +8,7 @@ namespace Input { GameController::GameController(unsigned) { - throw runtime_error("not supported"); + throw device_not_available("GameController"); } GameController::~GameController() diff --git a/source/input/touchscreen.cpp b/source/input/touchscreen.cpp index 4facb8c..c4de688 100644 --- a/source/input/touchscreen.cpp +++ b/source/input/touchscreen.cpp @@ -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";