fromValue static method

ErrorCode fromValue(
  1. int value
)

Returns the matching ErrorCode for a given integer value.

Returns ErrorCode.unspecified if no match is found.

Implementation

static ErrorCode fromValue(int value) {
  try {
    return ErrorCode.values.firstWhere((e) => e.value == value);
  } catch (e) {
    debugPrint('Unknown error code: $value');
    return ErrorCode.unspecified;
  }
}