mpu9150: 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 16:36:07 -06:00 committed by Mihai Tudor Panu
parent 9c4a4d0ff0
commit f6ab1fb451

View File

@ -49,7 +49,8 @@ bool MPU9150::init()
// init the gyro/accel component
if (!MPU60X0::init())
{
cerr << __FUNCTION__ << ": Unable to init MPU60X0" << endl;
throw std::runtime_error(std::string(__FUNCTION__) +
": Unable to init MPU60X0");
return false;
}
@ -57,7 +58,8 @@ bool MPU9150::init()
// will allow us to access the AK8975 Magnetometer on I2C addr 0x0c.
if (!enableI2CBypass(true))
{
cerr << __FUNCTION__ << ": Unable to enable I2C bypass" << endl;
throw std::runtime_error(std::string(__FUNCTION__) +
": Unable to enable I2C bypass");
return false;
}
@ -67,7 +69,8 @@ bool MPU9150::init()
if (!m_mag->init())
{
cerr << __FUNCTION__ << ": Unable to init magnetometer" << endl;
throw std::runtime_error(std::string(__FUNCTION__) +
": Unable to init magnetometer");
delete m_mag;
m_mag = 0;
return false;