How does one send an error while using Akka-gRPC. I'm aware of responseObserver.Error when using native gRPC interfaces but can't find the best way to do it in Akka-gRPC.
I've tried doing this, however i'm not certain if this is a good approach and besides it doesn't provide benefits of using the google. advance error model
override fun createUser(req: CreateUserRequest?): CompletionStage<User>{
requireNotNull(req)
val validations = validator.validate(req.user)
if (validations.isNotEmpty()) return CompletableFuture.failedStage(GrpcServiceException())
val user = User.newBuilder().build()
return CompletableFuture.completedFuture(user)
}
You can use the
GrpcServiceExceptionfor this: you can either fail theCompletionStagewith it, or throw it from thecreateUserbody.