mirror of
https://github.com/eclipse/upm.git
synced 2025-03-28 03:10:06 +03:00
th02: remove custom exception and use standard ones
Signed-off-by: Jon Trulson <jtrulson@ics.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
parent
448ee39c7f
commit
9bf954071b
@ -28,26 +28,21 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
#include "th02.h"
|
#include "th02.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace upm;
|
using namespace upm;
|
||||||
|
|
||||||
struct TH02Exception : public std::exception {
|
|
||||||
std::string message;
|
|
||||||
TH02Exception (std::string msg) : message (msg) { }
|
|
||||||
~TH02Exception () throw () { }
|
|
||||||
const char* what() const throw () { return message.c_str(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
TH02::TH02 (int bus, uint8_t addr) : m_i2c(bus) {
|
TH02::TH02 (int bus, uint8_t addr) : m_i2c(bus) {
|
||||||
m_addr = addr;
|
m_addr = addr;
|
||||||
m_name = "TH02";
|
m_name = "TH02";
|
||||||
|
|
||||||
mraa_result_t ret = m_i2c.address(m_addr);
|
mraa_result_t ret = m_i2c.address(m_addr);
|
||||||
if (ret != MRAA_SUCCESS) {
|
if (ret != MRAA_SUCCESS) {
|
||||||
throw TH02Exception ("Couldn't initilize I2C.");
|
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||||
|
": mraa_i2c_address() failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user