question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow specifying `Metadata` with `GrpcServiceBuilder.addExceptionMapping()`

See original GitHub issue

Related StackOverflow question: https://stackoverflow.com/questions/65838522/is-there-any-way-to-use-rich-error-model-for-grpc-service-in-armeria

It is currently not possible for a user to specify a custom Metadata when an exception is translated into a Status via the exception mapping function built from what’s specified with GrpcServiceBuilder.addExceptionMapping(). It may be useful if a user can specify Metadata as well as Status when adding an exception mapping:

GrpcService
  .builder()
  ...
  .addExceptionMapping(MyException.class, Status.INTERNAL_ERROR, myMetadata)
  .build();

We’re gonna have to update the signature of GrpcStatusFunction.apply() to support this use case. GrpcStatusFunction is an unstable API fortunately (?).

As a workaround, a user can write an interceptor like this (Kotlin code by @okue).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
okuecommented, Feb 3, 2021

Currently, I tried updating the signature of GrpcStatusFunction. https://github.com/okue/armeria/pull/6

After refactoring, writing test cases and examples, I’ll send a pull request.

0reactions
okuecommented, Feb 1, 2021

Ah, I don’t mention addExceptionMapping().

Read more comments on GitHub >

github_iconTop Results From Across the Web

GrpcServiceBuilder - armeria-javadoc 1.20.3 javadoc
Adds the specified exception mapping that maps a Throwable to a gRPC Status . ... Deprecated. Use addExceptionMapping(Class, GrpcStatusFunction) instead.
Read more >
How do I access request metadata for a java grpc service I am ...
Use a ServerInterceptor and then propagate the identity via Context . This allows you to have a central policy for authentication.
Read more >
Running a gRPC service — Armeria documentation
If you don't want your GrpcService support all those formats, specify the formats you want using GrpcServiceBuilder.supportedSerializationFormats() .
Read more >
Core concepts, architecture and lifecycle - gRPC
Like many RPC systems, gRPC is based around the idea of defining a service ... The server can then either send back its...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found