From 74cbc25f21c2c796767b718de63af14105f86c06 Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Tue, 8 Sep 2015 15:43:52 -0600 Subject: [PATCH] ppd42ns: throw exception(s) on fatal errors Signed-off-by: Jon Trulson Signed-off-by: Mihai Tudor Panu --- src/ppd42ns/ppd42ns.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ppd42ns/ppd42ns.cxx b/src/ppd42ns/ppd42ns.cxx index afd4f00a..a7b0e0db 100644 --- a/src/ppd42ns/ppd42ns.cxx +++ b/src/ppd42ns/ppd42ns.cxx @@ -23,6 +23,8 @@ */ #include +#include +#include #include #include #include @@ -34,7 +36,13 @@ using namespace upm; PPD42NS::PPD42NS(int pin) { - m_gpio = mraa_gpio_init(pin); + if ( !(m_gpio = mraa_gpio_init(pin)) ) + { + throw std::invalid_argument(std::string(__FUNCTION__) + + ": mraa_gpio_init() failed, invalid pin?"); + return; + } + mraa_gpio_dir(m_gpio, MRAA_GPIO_IN); }