From c878283c446479e5f43225a20ce75f5e9a08c149 Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Fri, 7 Aug 2015 16:36:02 -0600 Subject: [PATCH] max31723: remove custom exception and use standard ones Signed-off-by: Jon Trulson Signed-off-by: Mihai Tudor Panu --- src/max31723/max31723.cxx | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/max31723/max31723.cxx b/src/max31723/max31723.cxx index f00f5d46..b1d1a183 100644 --- a/src/max31723/max31723.cxx +++ b/src/max31723/max31723.cxx @@ -25,37 +25,34 @@ #include #include #include +#include #include "max31723.h" using namespace upm; -struct MAX31723Exception : public std::exception { - std::string message; - MAX31723Exception (std::string msg) : message (msg) { } - ~MAX31723Exception () throw () { } - const char* what() const throw () { return message.c_str(); } -}; - MAX31723::MAX31723 (int csn) { mraa_result_t error = MRAA_SUCCESS; m_name = "MAX31723"; m_csnPinCtx = mraa_gpio_init (csn); if (m_csnPinCtx == NULL) { - throw MAX31723Exception ("GPIO failed to initilize"); + throw std::invalid_argument(std::string(__FUNCTION__) + + ": mraa_gpio_init() failed"); } error = mraa_gpio_dir (m_csnPinCtx, MRAA_GPIO_OUT); if (error != MRAA_SUCCESS) { - throw MAX31723Exception ("GPIO failed to initilize"); + throw std::invalid_argument(std::string(__FUNCTION__) + + ": mraa_gpio_dir() failed"); } CSOff (); m_spi = mraa_spi_init (0); if (m_spi == NULL) { - throw MAX31723Exception ("SPI failed to initilize"); + throw std::invalid_argument(std::string(__FUNCTION__) + + ": mraa_spi_init() failed"); } // set spi mode to mode2 (CPOL = 1, CPHA = 0)