ssd1308: 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 13:09:23 -06:00 committed by Mihai Tudor Panu
parent fe133d7454
commit cb6427b22e

View File

@ -22,6 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdexcept>
#include <string>
#include <unistd.h>
@ -37,7 +38,8 @@ SSD1308::SSD1308(int bus_in, int addr_in) : m_i2c_lcd_control(bus_in)
mraa::Result error = m_i2c_lcd_control.address(m_lcd_control_address);
if (error != mraa::SUCCESS) {
fprintf(stderr, "Failed to initialize i2c bus\n");
throw std::invalid_argument(std::string(__FUNCTION__) +
": I2c.address() failed");
return;
}