grovescam: throw exception(s) on fatal read() as well

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Jon Trulson 2015-09-10 11:50:32 -06:00 committed by Mihai Tudor Panu
parent 8d38bd0bcc
commit 56ddb441d4

View File

@ -119,7 +119,12 @@ int GROVESCAM::readData(uint8_t *buffer, int len)
int rv = read(m_ttyFd, (char *)buffer, len);
if (rv < 0)
cerr << __FUNCTION__ << ": read failed: " << strerror(errno) << endl;
{
throw std::runtime_error(std::string(__FUNCTION__) +
": read() failed: " +
string(strerror(errno)));
return rv;
}
return rv;
}