Class GrpcResponse<T>

java.lang.Object
com.codename1.io.grpc.GrpcResponse<T>

public final class GrpcResponse<T> extends Object

Result of a unary gRPC call. Mirrors the shape of Response so call sites that already use the REST helpers feel at home, but the integer status code returned by getResponseCode() is the gRPC status, not the HTTP one:

  • 0 -- OK. Wire-level success.
  • 1..16 -- standard gRPC statuses (CANCELLED, UNKNOWN, ...).
  • -1 -- the transport itself failed (network error, HTTP non-200, missing status trailer). getHttpCode() still returns the underlying HTTP code in that case.

Use isOk() for the common "request succeeded" check.

  • Field Details

  • Constructor Details

    • GrpcResponse

      public GrpcResponse(int grpcStatus, int httpCode, T responseData, String responseMessage)
  • Method Details

    • getResponseData

      public T getResponseData()
      The deserialised response message, or null when the call failed or the server returned an empty body.
    • getResponseCode

      public int getResponseCode()
      The gRPC status code. 0 is success; non-zero codes follow the standard gRPC status enumeration. -1 (STATUS_TRANSPORT_FAILURE) signals a transport-level error -- the call never reached grpc-status.
    • getHttpCode

      public int getHttpCode()
      The underlying HTTP status code. Usually 200 even for a non-zero gRPC status, because the server returns gRPC errors in trailers rather than via HTTP status. Useful when getResponseCode() is STATUS_TRANSPORT_FAILURE.
    • isOk

      public boolean isOk()
      true iff getResponseCode() is 0 (gRPC OK).
    • getResponseErrorMessage

      public String getResponseErrorMessage()
      The server-supplied grpc-message trailer (or the HTTP error message when the call failed before reaching the trailer).