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

Method fromThrowable

api/src/main/java/io/grpc/Status.java:396–408  ·  view source on GitHub ↗

Extract an error Status from the causal chain of a Throwable. If no status can be found, a status is created with Code#UNKNOWN as its code and t as its cause. @return non-null status

(Throwable t)

Source from the content-addressed store, hash-verified

394 * @return non-{@code null} status
395 */
396 public static Status fromThrowable(Throwable t) {
397 Throwable cause = checkNotNull(t, "t");
398 while (cause != null) {
399 if (cause instanceof StatusException) {
400 return ((StatusException) cause).getStatus();
401 } else if (cause instanceof StatusRuntimeException) {
402 return ((StatusRuntimeException) cause).getStatus();
403 }
404 cause = cause.getCause();
405 }
406 // Couldn't find a cause with a Status
407 return UNKNOWN.withCause(t);
408 }
409
410 /**
411 * Extract an error trailers from the causal chain of a {@link Throwable}.

Calls 4

checkNotNullMethod · 0.80
getCauseMethod · 0.80
withCauseMethod · 0.80
getStatusMethod · 0.65