下面列出了io.grpc.Status#asException ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static Digest putBlob(
Instance instance,
Digest digest,
ByteString blob,
long writeDeadlineAfter,
TimeUnit writeDeadlineAfterUnits,
RequestMetadata requestMetadata)
throws ExcessiveWriteSizeException, IOException, InterruptedException, StatusException {
try {
return putBlobFuture(
instance, digest, blob, writeDeadlineAfter, writeDeadlineAfterUnits, requestMetadata)
.get();
} catch (ExecutionException e) {
Throwable cause = e.getCause();
if (cause instanceof IOException) {
throw (IOException) cause;
}
Status status = Status.fromThrowable(cause);
throw status.asException();
}
}
public void notifyShutdown(Status s) {
if (transportShutdown) {
return;
}
transportShutdown = true;
shutdownStatus = s;
shutdownThrowable = s.asException();
listener.transportShutdown(s);
}
@Override
public void closed(Status status, RpcProgress rpcProgress, Metadata trailers) {
if (status.isOk()) {
closedFuture.set(null);
} else {
StatusException e = status.asException();
closedFuture.setException(e);
responseFuture.setException(e);
}
}
private void closeListener(Status newStatus) {
if (!listenerClosed) {
listenerClosed = true;
setClientStreamClosed();
messageFramer.close();
ctx.logBuilder().responseContent(GrpcLogUtil.rpcResponse(newStatus, firstResponse), null);
if (newStatus.isOk()) {
if (blockingExecutor != null) {
blockingExecutor.execute(this::invokeOnComplete);
} else {
invokeOnComplete();
}
} else {
cancelled = true;
if (blockingExecutor != null) {
blockingExecutor.execute(this::invokeOnCancel);
} else {
invokeOnCancel();
}
// Transport error, not business logic error, so reset the stream.
if (!closeCalled) {
final StatusException statusException = newStatus.asException();
final Throwable cause = statusException.getCause();
if (cause != null) {
res.close(cause);
} else {
res.abort();
}
}
}
}
}
public void notifyShutdown(Status s) {
notifyGracefulShutdown(s);
if (shutdownStatus != null) {
return;
}
shutdownStatus = s;
shutdownThrowable = s.asException();
}
@Override
public void closed(Status status, RpcProgress rpcProgress, Metadata trailers) {
if (status.isOk()) {
closedFuture.set(null);
} else {
StatusException e = status.asException();
closedFuture.setException(e);
responseFuture.setException(e);
}
}
public static FirebaseFirestoreException exceptionFromStatus(Status error) {
StatusException statusException = error.asException();
return new FirebaseFirestoreException(
statusException.getMessage(), Code.fromValue(error.getCode().value()), statusException);
}