use of io.servicetalk.http.api.Http2Exception in project servicetalk by apple.
the class GrpcUtils method toGrpcStatus.
static GrpcStatus toGrpcStatus(Throwable cause) {
final GrpcStatus status;
if (cause instanceof Http2Exception) {
Http2Exception h2Exception = (Http2Exception) cause;
status = new GrpcStatus(fromHttp2ErrorCode(h2Exception.errorCode()), cause);
} else if (cause instanceof MessageEncodingException) {
MessageEncodingException msgEncException = (MessageEncodingException) cause;
status = new GrpcStatus(UNIMPLEMENTED, cause, "Message encoding '" + msgEncException.encoding() + "' not supported ");
} else if (cause instanceof SerializationException) {
status = new GrpcStatus(UNKNOWN, cause, "Serialization error: " + cause.getMessage());
} else if (cause instanceof CancellationException) {
status = new GrpcStatus(CANCELLED, cause);
} else if (cause instanceof TimeoutException) {
status = new GrpcStatus(DEADLINE_EXCEEDED, cause);
} else {
// Initialize detail because cause is often lost
status = new GrpcStatus(UNKNOWN, cause, cause.toString());
}
return status;
}
Aggregations