Allow StatusException to set its own headers
This commit is contained in:
@@ -85,7 +85,7 @@ public class GrpcExceptionHandlerInterceptor implements ServerInterceptor {
|
||||
super.onReady();
|
||||
}
|
||||
catch (Throwable t) {
|
||||
this.call.close(this.exceptionHandler.handleException(t), new Metadata());
|
||||
this.call.close(this.exceptionHandler.handleException(t), headers(t));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class GrpcExceptionHandlerInterceptor implements ServerInterceptor {
|
||||
super.onMessage(message);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
this.call.close(this.exceptionHandler.handleException(t), new Metadata());
|
||||
this.call.close(this.exceptionHandler.handleException(t), headers(t));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,10 +105,15 @@ public class GrpcExceptionHandlerInterceptor implements ServerInterceptor {
|
||||
super.onHalfClose();
|
||||
}
|
||||
catch (Throwable t) {
|
||||
this.call.close(this.exceptionHandler.handleException(t), new Metadata());
|
||||
this.call.close(this.exceptionHandler.handleException(t), headers(t));
|
||||
}
|
||||
}
|
||||
|
||||
private Metadata headers(Throwable t) {
|
||||
Metadata result = Status.trailersFromThrowable(t);
|
||||
return result != null ? result : new Metadata();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class FallbackHandler implements GrpcExceptionHandler {
|
||||
|
||||
Reference in New Issue
Block a user