From 1079baf2fdac1e2eb4469e4fcecf9978b68b8d56 Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Wed, 9 Sep 2015 16:38:17 -0600 Subject: [PATCH] gp2y0a: throw exception(s) on fatal errors Signed-off-by: Jon Trulson Signed-off-by: Mihai Tudor Panu --- src/gp2y0a/gp2y0a.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gp2y0a/gp2y0a.cxx b/src/gp2y0a/gp2y0a.cxx index 6943d0b9..07abc7d3 100644 --- a/src/gp2y0a/gp2y0a.cxx +++ b/src/gp2y0a/gp2y0a.cxx @@ -23,6 +23,8 @@ */ #include +#include +#include #include "gp2y0a.h" @@ -33,7 +35,8 @@ GP2Y0A::GP2Y0A(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; }