From 2e0efd66905750214425fe3d7c722a413b711802 Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Fri, 7 Aug 2015 16:36:21 -0600 Subject: [PATCH] max5487: remove custom exception and use standard ones Signed-off-by: Jon Trulson Signed-off-by: Mihai Tudor Panu --- src/max5487/max5487.cxx | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/max5487/max5487.cxx b/src/max5487/max5487.cxx index 44c917c6..23c5d8c7 100644 --- a/src/max5487/max5487.cxx +++ b/src/max5487/max5487.cxx @@ -25,18 +25,12 @@ #include #include #include +#include #include "max5487.h" using namespace upm; -struct MAX5487Exception : public std::exception { - std::string message; - MAX5487Exception (std::string msg) : message (msg) { } - ~MAX5487Exception () throw () { } - const char* what() const throw () { return message.c_str(); } -}; - MAX5487::MAX5487 (int csn) { mraa_result_t error = MRAA_SUCCESS; m_name = "MAX5487"; @@ -45,18 +39,21 @@ MAX5487::MAX5487 (int csn) { if (csn != -1) { m_csnPinCtx = mraa_gpio_init (csn); if (m_csnPinCtx == NULL) { - throw MAX5487Exception ("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 MAX5487Exception ("GPIO failed to initilize"); + throw std::invalid_argument(std::string(__FUNCTION__) + + ": mraa_gpio_dir() failed"); } } m_spi = mraa_spi_init (0); if (m_spi == NULL) { - throw MAX5487Exception ("SPI failed to initilize"); + throw std::invalid_argument(std::string(__FUNCTION__) + + ": mraa_spi_init() failed"); } CSOff ();