Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java implementation #4

Open
BulatMukhutdinov opened this issue Oct 19, 2017 · 4 comments
Open

Java implementation #4

BulatMukhutdinov opened this issue Oct 19, 2017 · 4 comments

Comments

@BulatMukhutdinov
Copy link

Hi
Thank you for your nice lib!
Can you please also provide an example in Java?

@avinassh
Copy link
Owner

avinassh commented Nov 3, 2017

Hi @BulatMukhutdinov, it might take some time with Java examples as I am not really a Java dev. However I will keep this issue open and hope someone contributes

@simplesteph
Copy link

See https://github.com/saturnism/grpc-java-by-example/tree/master/error-handling-example/error-server/src/main/java/com/example/grpc/server

Maybe you could get inspired / get a PR from the author

@jyiL
Copy link

jyiL commented Jun 27, 2018

@avinassh Hi,Can you please also provide an example in PHP?

@mfickett
Copy link

mfickett commented Oct 2, 2020

Thanks @simplesteph for the pointer. It looks like https://github.com/saturnism/grpc-by-example-java/blob/master/error-handling-example/error-server/src/main/java/com/example/grpc/server/ErrorServiceImpl.java#L33 is they key example:

  @Override
  public void customException(EchoRequest request, StreamObserver<EchoResponse> responseObserver) {
    try {
      throw new CustomException("Custom exception!");
    } catch (Exception e) {
      responseObserver.onError(Status.INTERNAL
          .withDescription(e.getMessage())
          .augmentDescription("customException()")
          .withCause(e) // This can be attached to the Status locally, but NOT transmitted to the client!
          .asRuntimeException());
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants