getSerialErrorCode static method

SerialErrorCode getSerialErrorCode(
  1. int value
)

Converts the native error code value to SerialErrorCode.

Implementation

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

  // check range
  if (value > SerialErrorCode.serialErrorClose.index) {
    return SerialErrorCode.errorCodeNotMappable;
  }

  return SerialErrorCode.values[value];
}