You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Priority of mapped exceptions](#priority-of-mapped-exceptions)
12
+
-[Sending Metadata in response](#sending-metadata-in-response)
13
+
-[Overview of returnable types](#overview-of-returnable-types)
11
14
12
15
## Additional Topics <!-- omit in toc -->
13
16
@@ -18,9 +21,78 @@ This section describes how you can handle exceptions inside GrpcService layer wi
18
21
-[Testing the Service](testing.md)
19
22
-[Security](security.md)
20
23
21
-
## TODO ...
24
+
## Proper exception handling
25
+
If you are already familiar with springs [error handling](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-error-handling),
26
+
you should see some similarity with intended exception handling for gRPC.
Status status =Status.NOT_FOUND.withDescription(e.getMessage());
43
+
Metadata metadata =...
44
+
return status.asException(metadata);
45
+
}
46
+
47
+
}
48
+
```
49
+
50
+
-`@GrpcAdvice` marks a class to be picked up for exception handling
51
+
-`@GrpcExceptionHandler` maps given method to be executed, in case of _specified_ thrown exception
52
+
- f.e. if your application throws `IllegalArgumentException`, method `handleIllegalArgumentException(..)` is executed
53
+
-`io.grpc.Status` is specified and returned response status
54
+
55
+
> **Note:** Cause is not transmitted from server to client - as stated in [official docs](https://grpc.github.io/grpc-java/javadoc/io/grpc/Status.html#withCause-java.lang.Throwable-)
56
+
57
+
## Detailed explanation
58
+
59
+
### Priority of mapped exceptions
60
+
Given method with specified Exception in Annotation *and* as method argument
0 commit comments