getI2CerrorCode static method

I2CerrorCode getI2CerrorCode(
  1. int value
)

Converts the native error code value to I2CerrorCode.

Implementation

static I2CerrorCode getI2CerrorCode(int value) {
  // must be negative
  if (value >= 0) {
    return I2CerrorCode.errorCodeNotMappable;
  }
  value = -value;

  // check range
  if (value > I2CerrorCode.i2cErrorClose.index) {
    return I2CerrorCode.errorCodeNotMappable;
  }

  return I2CerrorCode.values[value];
}