sx6119: throw exception(s) on fatal errors

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Jon Trulson 2015-09-11 12:12:34 -06:00 committed by Mihai Tudor Panu
parent 3585761ecf
commit 619da95553

View File

@ -24,6 +24,8 @@
#include <unistd.h>
#include <iostream>
#include <string>
#include <stdexcept>
#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;
}