-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Cannot throw custome runtime exception inside clientinterceptor #3434
Comments
Is it possible to throw my custom exception inside ClientInterceptor? |
You can throw whatever you want, but we will always wrap it in a StatusRuntimeException or StatusException. It will be set as the cause in the the Status. |
It's generally best not to throw within an interceptor. Instead call cancel() directly. Throwing should be more when there is a bug (so any exceptions from the reflection would probably be fine, but returnCode seems better for graceful handling. |
Yes, i am currently in client team. We want to handle runtime exception by converting code (with http code standard) that server send as response because stacktrace thread server cannot be send to client. We have standard to use code and message to check what kind of error we get from server. So i thought that it can be handle with:
|
Please answer these questions before submitting your issue.
What version of gRPC are you using?
1.4.0
What JVM are you using (
java -version
)?1.8.0_144
What did you do?
If possible, provide a recipe for reproducing the error.
So i was trying to use ClientInterceptor by overiding onMessage(RespT message). So i'm trying to throw my custome runtime exception inside ForwaringClientCall.listener something like this
Field code;
What did you expect to see?
I excpect it will throw my custom exception
What did you see instead?
it always end inside inside this method
catch (Throwable t)
and it will end with statusruntimeexception cancelThank you for your attention
The text was updated successfully, but these errors were encountered: