From f6ab1fb4519b7a2c084ab517feff2db894cf3fa3 Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Thu, 10 Sep 2015 16:36:07 -0600 Subject: [PATCH] mpu9150: throw exception(s) on fatal errors Signed-off-by: Jon Trulson Signed-off-by: Mihai Tudor Panu --- src/mpu9150/mpu9150.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/mpu9150/mpu9150.cxx b/src/mpu9150/mpu9150.cxx index e8961655..a4463a9c 100644 --- a/src/mpu9150/mpu9150.cxx +++ b/src/mpu9150/mpu9150.cxx @@ -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;