From 3ad25f65c84418a09daf69bb92db3fd705a88659 Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Fri, 7 Aug 2015 16:01:24 -0600 Subject: [PATCH] lpd8806: remove custom exception and use a standard one Signed-off-by: Jon Trulson Signed-off-by: Mihai Tudor Panu --- src/lpd8806/lpd8806.cxx | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/lpd8806/lpd8806.cxx b/src/lpd8806/lpd8806.cxx index 282fd610..894634e6 100644 --- a/src/lpd8806/lpd8806.cxx +++ b/src/lpd8806/lpd8806.cxx @@ -26,18 +26,12 @@ #include #include #include +#include #include "lpd8806.h" using namespace upm; -struct LPD8806Exception : public std::exception { - std::string message; - LPD8806Exception (std::string msg) : message (msg) { } - ~LPD8806Exception () throw () { } - const char* what() const throw () { return message.c_str(); } -}; - LPD8806::LPD8806 (uint16_t pixelCount, uint8_t csn) { mraa_result_t error = MRAA_SUCCESS; m_name = "LPD8806"; @@ -46,19 +40,22 @@ LPD8806::LPD8806 (uint16_t pixelCount, uint8_t csn) { m_csnPinCtx = mraa_gpio_init (csn); if (m_csnPinCtx == NULL) { - throw LPD8806Exception ("GPIO failed to initilize"); + throw std::invalid_argument(std::string(__FUNCTION__) + + ": GPIO failed to initialize"); } error = mraa_gpio_dir (m_csnPinCtx, MRAA_GPIO_OUT); if (error != MRAA_SUCCESS) { - throw LPD8806Exception ("GPIO failed to initilize"); + throw std::invalid_argument(std::string(__FUNCTION__) + + ": GPIO failed to set direction"); } CSOff (); m_spi = mraa_spi_init (0); if (m_spi == NULL) { - throw LPD8806Exception ("SPI failed to initilize"); + throw std::invalid_argument(std::string(__FUNCTION__) + + ": SPI failed to initialize"); } // set spi mode to mode2 (CPOL = 0, CPHA = 0)