Hi , 

I wonder how to implement a  'global runtime exception interceptor' , 
that intercepts all server runtime exceptions , and auto 

*responseObserver.onError(new 
StatusRuntimeException(Status.INTERNAL.withDescription(e.getMessage())));*

so that in the server code, we don't need to try catch RuntimeException , and 
write the above code in each method call.


Thanks a lot.

Smallufo Huang於 2016年9月30日星期五 UTC+8下午8時21分54秒寫道:
>
>
>
> Eric Anderson於 2016年4月22日星期五 UTC+8下午10時30分29秒寫道:
>>
>> You can create a ServerInterceptor that can copy any cause message to the 
>> status.
>>
>> public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
>>       MethodDescriptor<ReqT, RespT> method,
>>       ServerCall<RespT> call,
>>       Metadata headers,
>>       ServerCallHandler<ReqT, RespT> next) {
>>   return new SimpleForwardingServerCall(
>>       next.startCall(method, call, headers)) {
>>     @Override
>>     public void close(Status status, String message) {
>>       if (status.getDescription() == null
>>           && status.getCause() != null) {
>>         status = status.withDescription(
>>             status.getCause().getMessage());
>>       }
>>       super.close(status, message):
>>     }
>>   };
>> }
>>
>
>
>
> Hi , it seems the signature changed in 1.0.0
> Is there a 1.0.0 version of ServerInterceptor  (that translate the 
> underlaying Exception to String ) 
>
>
>
>
>
>
>
>
>
>
>
>
> *private ServerInterceptor serverInterceptor = new ServerInterceptor() {  
> @Override  public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(    
> ServerCall<ReqT, RespT> serverCall,    Metadata metadata,    
> ServerCallHandler<ReqT, RespT> next) {    logger.info("intercept {}" , 
> serverCall.getMethodDescriptor().getFullMethodName());    // how to replace 
> the following line ?    return next.startCall(serverCall, metadata);  }};*
>
>
>
> How to replace the next.startCall() line ?
>
> Thanks a lot ! 
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/941489a9-6898-4a0f-aad9-683beab67cb4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to