grpc-kotlin icon indicating copy to clipboard operation
grpc-kotlin copied to clipboard

example of how to return errors

Open pelicanlion opened this issue 2 years ago • 2 comments
trafficstars

Are there examples of how to return error responses using Kotlin styled builders?

For example, something like this:

Status.newBuilder()
  .setCode(Code.INTERNAL_VALUE)
  .addDetails(Any.pack(details))
  .build()

but with this style of syntax

status {
  code = Code.INTERNAL_VALUE
  details = any {
     pack(details)
  }
}

If this is possible how does one import these builders?

pelicanlion avatar Aug 23 '23 05:08 pelicanlion

Seems like something grpc-kotlin could provide a nice wrapper around but I don't think it currently does.

jamesward avatar Aug 23 '23 19:08 jamesward

@jamesward is correct; we do not currently provide any API like this. I think there also may be confusion between io.grpc.Status and com.google.rpc.Status, the latter of which would just use Kotlin protobufs, which is a separate project from gRPC-Kotlin. It's not clear to me that com.google.rpc.Status actually has any specific relationship with gRPC other than being used in some RPC services. io.grpc.Status is, as far as I'm aware, the only type with specific API and handling from the gRPC API.

lowasser avatar Aug 23 '23 19:08 lowasser