fromValue static method

ErrorCode fromValue(
  1. int value
)

Returns the corresponding ErrorCode enum for a given integer value.

If the provided integer value does not match any defined ErrorCode, the method returns null.

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;
  }
}