Java Code Examples for io.grpc.Status#augmentDescription()

The following examples show how to use io.grpc.Status#augmentDescription() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OkHttpClientTransport.java    From grpc-nebula-java with Apache License 2.0 6 votes vote down vote up
@Override
public void goAway(int lastGoodStreamId, ErrorCode errorCode, ByteString debugData) {
  if (errorCode == ErrorCode.ENHANCE_YOUR_CALM) {
    String data = debugData.utf8();
    log.log(Level.WARNING, String.format(
        "%s: Received GOAWAY with ENHANCE_YOUR_CALM. Debug data: %s", this, data));
    if ("too_many_pings".equals(data)) {
      tooManyPingsRunnable.run();
    }
  }
  Status status = GrpcUtil.Http2Error.statusForCode(errorCode.httpCode)
      .augmentDescription("Received Goaway");
  if (debugData.size() > 0) {
    // If a debug message was provided, use it.
    status = status.augmentDescription(debugData.utf8());
  }
  startGoAway(lastGoodStreamId, null, status);
}
 
Example 2
Source File: Http2ClientStreamTransportState.java    From grpc-nebula-java with Apache License 2.0 6 votes vote down vote up
/**
 * Extract the response status from trailers.
 */
private Status statusFromTrailers(Metadata trailers) {
  Status status = trailers.get(InternalStatus.CODE_KEY);
  if (status != null) {
    return status.withDescription(trailers.get(InternalStatus.MESSAGE_KEY));
  }
  // No status; something is broken. Try to provide a resonanable error.
  if (headersReceived) {
    return Status.UNKNOWN.withDescription("missing GRPC status in response");
  }
  Integer httpStatus = trailers.get(HTTP2_STATUS);
  if (httpStatus != null) {
    status = GrpcUtil.httpStatusToGrpcStatus(httpStatus);
  } else {
    status = Status.INTERNAL.withDescription("missing HTTP status code");
  }
  return status.augmentDescription(
      "missing GRPC status, inferred error from HTTP status code");
}
 
Example 3
Source File: OkHttpClientTransport.java    From grpc-java with Apache License 2.0 6 votes vote down vote up
@Override
public void goAway(int lastGoodStreamId, ErrorCode errorCode, ByteString debugData) {
  logger.logGoAway(OkHttpFrameLogger.Direction.INBOUND, lastGoodStreamId, errorCode, debugData);
  if (errorCode == ErrorCode.ENHANCE_YOUR_CALM) {
    String data = debugData.utf8();
    log.log(Level.WARNING, String.format(
        "%s: Received GOAWAY with ENHANCE_YOUR_CALM. Debug data: %s", this, data));
    if ("too_many_pings".equals(data)) {
      tooManyPingsRunnable.run();
    }
  }
  Status status = GrpcUtil.Http2Error.statusForCode(errorCode.httpCode)
      .augmentDescription("Received Goaway");
  if (debugData.size() > 0) {
    // If a debug message was provided, use it.
    status = status.augmentDescription(debugData.utf8());
  }
  startGoAway(lastGoodStreamId, null, status);
}
 
Example 4
Source File: Http2ClientStreamTransportState.java    From grpc-java with Apache License 2.0 6 votes vote down vote up
/**
 * Extract the response status from trailers.
 */
private Status statusFromTrailers(Metadata trailers) {
  Status status = trailers.get(InternalStatus.CODE_KEY);
  if (status != null) {
    return status.withDescription(trailers.get(InternalStatus.MESSAGE_KEY));
  }
  // No status; something is broken. Try to provide a resonanable error.
  if (headersReceived) {
    return Status.UNKNOWN.withDescription("missing GRPC status in response");
  }
  Integer httpStatus = trailers.get(HTTP2_STATUS);
  if (httpStatus != null) {
    status = GrpcUtil.httpStatusToGrpcStatus(httpStatus);
  } else {
    status = Status.INTERNAL.withDescription("missing HTTP status code");
  }
  return status.augmentDescription(
      "missing GRPC status, inferred error from HTTP status code");
}
 
Example 5
Source File: NettyClientHandler.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
private Status statusFromGoAway(long errorCode, byte[] debugData) {
  Status status = GrpcUtil.Http2Error.statusForCode((int) errorCode)
      .augmentDescription("Received Goaway");
  if (debugData != null && debugData.length > 0) {
    // If a debug message was provided, use it.
    String msg = new String(debugData, UTF_8);
    status = status.augmentDescription(msg);
  }
  return status;
}
 
Example 6
Source File: NettyClientHandler.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
private Status statusFromGoAway(long errorCode, byte[] debugData) {
  Status status = GrpcUtil.Http2Error.statusForCode((int) errorCode)
      .augmentDescription("Received Goaway");
  if (debugData != null && debugData.length > 0) {
    // If a debug message was provided, use it.
    String msg = new String(debugData, UTF_8);
    status = status.augmentDescription(msg);
  }
  return status;
}
 
Example 7
Source File: GrpcUtil.java    From grpc-nebula-java with Apache License 2.0 4 votes vote down vote up
Http2Error(int code, Status status) {
  this.code = code;
  this.status = status.augmentDescription("HTTP/2 error code: " + this.name());
}
 
Example 8
Source File: GrpcUtil.java    From grpc-java with Apache License 2.0 4 votes vote down vote up
Http2Error(int code, Status status) {
  this.code = code;
  this.status = status.augmentDescription("HTTP/2 error code: " + this.name());
}