valueOf static method

HttpStatusCode valueOf(
  1. int code
)

Return an {@code HttpStatusCode} object for the given integer value. @param code the status code as integer @return the corresponding {@code HttpStatusCode} @throws IllegalArgumentException if {@code code} is not a three-digit positive number

Implementation

static HttpStatusCode valueOf(int code) {
  assert(
    code >= 100 && code <= 999,
    'Status code $code should be a three-digit positive integer',
  );
  HttpStatus? status = HttpStatus.resolve(code);
  if (status != null) {
    return status;
  } else {
    return DefaultHttpStatusCode(code);
  }
}