Treehopper C++ API
I2cTransferException.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <stdexcept>
4 #include <string>
5 #include "Treehopper.h"
6 #include "I2cTransferError.h"
7 
8 using namespace std;
9 
10 namespace Treehopper {
11  class I2cTransferException : public std::runtime_error {
12  public:
13  I2cTransferException(I2cTransferError responseCode) : runtime_error(GetError(responseCode)) {
14 
15  }
16 
17  static string GetError(I2cTransferError code) {
18  switch (code) {
19  case I2cTransferError::ArbitrationLostError:
20  return string("I2c arbitration lost error");
21  break;
22 
23  case I2cTransferError::NackError:
24  return string("I2c nack error");
25  break;
26 
27  case I2cTransferError::Success:
28  return string("I2c success");
29  break;
30 
31  case I2cTransferError::TxunderError:
32  return string("I2c Tx underrun error");
33  break;
34 
35  default:
36  case I2cTransferError::UnknownError:
37  return string("I2c unknown error");
38  }
39  }
40  };
41 }
I2cTransferException(I2cTransferError responseCode)
Definition: I2cTransferException.h:13
Definition: I2cTransferException.h:11
static string GetError(I2cTransferError code)
Definition: I2cTransferException.h:17
Definition: AdcPin.h:3
I2cTransferError
Describes the transfer error, if not Success, that occured
Definition: I2cTransferError.h:9