If I have a code like below on a Java-based gRPC service

 @Override
  public void purge(
      final PurgeRequest request, final StreamObserver<PurgeResponse> 
responseObserver) {
      validator.validate(request);
      responseObserver.onNext(service.purge(request));
      responseObserver.onCompleted();
  }

Is it recommended that I catch the exception and call onError() like below 
or it is not recommended? Is there any advantage of one approach over the 
other?

 @Override
  public void purge(
      final PurgeRequest request, final StreamObserver<PurgeResponse> 
responseObserver) {
    try {
      validator.validate(request);
      responseObserver.onNext(gdprService.purge(request));
      responseObserver.onCompleted();
    } catch (final Exception e) {
      log.error("Failed to purge {}", request, e);
      responseObserver.onError(e);
    }
  }


-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to grpc-io+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/985e6aee-2de0-4ca4-b99e-f17e61297cc5n%40googlegroups.com.

Reply via email to