Allow specifying `Metadata` with `GrpcServiceBuilder.addExceptionMapping()`
See original GitHub issueRelated 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:
- Created 3 years ago
- Reactions:5
- Comments:6 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Currently, I tried updating the signature of
GrpcStatusFunction. https://github.com/okue/armeria/pull/6After refactoring, writing test cases and examples, I’ll send a pull request.
Ah, I don’t mention
addExceptionMapping().