From 667a8fdb492a733b81bc239a342b3cca3a43290c Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Tue, 8 Sep 2015 12:49:29 -0600 Subject: [PATCH] yg1006: throw exception(s) on fatal errors Signed-off-by: Jon Trulson Signed-off-by: Mihai Tudor Panu --- src/yg1006/yg1006.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/yg1006/yg1006.cxx b/src/yg1006/yg1006.cxx index 43d1c6a3..7ac721aa 100644 --- a/src/yg1006/yg1006.cxx +++ b/src/yg1006/yg1006.cxx @@ -23,6 +23,8 @@ */ #include +#include +#include #include "yg1006.h" @@ -33,7 +35,8 @@ YG1006::YG1006(int pin) { if ( !(m_gpio = mraa_gpio_init(pin)) ) { - cerr << __FUNCTION__ << ": mraa_gpio_init() failed" << endl; + throw std::invalid_argument(std::string(__FUNCTION__) + + ": mraa_gpio_init() failed, invalid pin?"); return; }