groveo2: 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-10 11:11:08 -06:00 committed by Mihai Tudor Panu
parent b56095a3ff
commit 5ab01e5a65

View File

@ -23,6 +23,8 @@
*/
#include <iostream>
#include <string>
#include <stdexcept>
#include "groveo2.h"
@ -33,7 +35,8 @@ GroveO2::GroveO2(int pin)
{
if ( !(m_aio = mraa_aio_init(pin)) )
{
cerr << __FUNCTION__ << ": mraa_aio_init() failed" << endl;
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_aio_init() failed, invalid pin?");
return;
}
}