MCPcopy Create free account
hub / github.com/grpc/grpc-java / fromCodeValueSlow

Method fromCodeValueSlow

api/src/main/java/io/grpc/Status.java:319–343  ·  view source on GitHub ↗
(byte[] asciiCodeValue)

Source from the content-addressed store, hash-verified

317 }
318
319 @SuppressWarnings("fallthrough")
320 private static Status fromCodeValueSlow(byte[] asciiCodeValue) {
321 int index = 0;
322 int codeValue = 0;
323 switch (asciiCodeValue.length) {
324 case 2:
325 if (asciiCodeValue[index] < '0' || asciiCodeValue[index] > '9') {
326 break;
327 }
328 codeValue += (asciiCodeValue[index++] - '0') * 10;
329 // fall through
330 case 1:
331 if (asciiCodeValue[index] < '0' || asciiCodeValue[index] > '9') {
332 break;
333 }
334 codeValue += asciiCodeValue[index] - '0';
335 if (codeValue < STATUS_LIST.size()) {
336 return STATUS_LIST.get(codeValue);
337 }
338 break;
339 default:
340 break;
341 }
342 return UNKNOWN.withDescription("Unknown code " + new String(asciiCodeValue, US_ASCII));
343 }
344
345 /**
346 * Return a {@link Status} given a canonical error {@link Code} object.

Callers 1

fromCodeValueMethod · 0.95

Calls 3

withDescriptionMethod · 0.80
sizeMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected