From 619da95553c6d97993d2b463d23432f2ce58389a Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Fri, 11 Sep 2015 12:12:34 -0600 Subject: [PATCH] sx6119: throw exception(s) on fatal errors Signed-off-by: Jon Trulson Signed-off-by: Mihai Tudor Panu --- src/sx6119/sx6119.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sx6119/sx6119.cxx b/src/sx6119/sx6119.cxx index 402627dc..caa8d966 100644 --- a/src/sx6119/sx6119.cxx +++ b/src/sx6119/sx6119.cxx @@ -24,6 +24,8 @@ #include #include +#include +#include #include "sx6119.h" @@ -34,7 +36,8 @@ SX6119::SX6119(int powerPin, int seekPin) { if ( !(m_gpioPower = mraa_gpio_init(powerPin)) ) { - cerr << __FUNCTION__ << ": mraa_gpio_init() failed" << endl; + throw std::invalid_argument(std::string(__FUNCTION__) + + ": mraa_gpio_init(power) failed, invalid pin?"); return; } @@ -43,7 +46,8 @@ SX6119::SX6119(int powerPin, int seekPin) if ( !(m_gpioSeek = mraa_gpio_init(seekPin)) ) { - cerr << __FUNCTION__ << ": mraa_gpio_init() failed" << endl; + throw std::invalid_argument(std::string(__FUNCTION__) + + ": mraa_gpio_init(seek) failed, invalid pin?"); return; }