Fix: Don't throw const char* but std::runtime_erro
This commit is contained in:
parent
dd51803e15
commit
059dee7d4b
|
|
@ -98,8 +98,7 @@ void HumiReader::setCallback(std::function<bool(const HumiResult&)> cb) {
|
|||
|
||||
void HumiReader::run() {
|
||||
if (!setupDevice()) {
|
||||
throw std::runtime_error("Can't setup device\n");
|
||||
//throw "Can't setup device";
|
||||
throw std::runtime_error("Can't setup device");
|
||||
}
|
||||
cancelLoop = false;
|
||||
hasIResult = false;
|
||||
|
|
@ -108,17 +107,17 @@ void HumiReader::run() {
|
|||
char buf[32+1];
|
||||
char outbuf[256];
|
||||
unsigned int outbufsiz =0;
|
||||
unsigned int sleepMax = 10000;
|
||||
int sleepMax = 10000;
|
||||
|
||||
while(!cancelLoop) {
|
||||
int siz = read(fd, buf, sizeof(buf)-1);
|
||||
if (siz < 0) {
|
||||
if (errno != EAGAIN) {
|
||||
throw "Read failed";
|
||||
throw std::runtime_error("Read failed");
|
||||
}
|
||||
else {
|
||||
if (sleepMax <= 0) {
|
||||
throw "Timeout";
|
||||
throw std::runtime_error("Timeout");
|
||||
}
|
||||
usleep(10*1000);
|
||||
sleepMax -= 10;
|
||||
|
|
|
|||
Loading…
Reference in New Issue