mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-22 22:45:21 +01:00
Permit some gRPC excptions to be logged only as warning
A new handleExceptionAsWarning method logs warn(ex.msg) instead of the full stack trace.
This commit is contained in:
parent
e5291e9f45
commit
e5a0a3998d
1 changed files with 14 additions and 1 deletions
|
@ -46,7 +46,9 @@ class GrpcExceptionHandler {
|
|||
public GrpcExceptionHandler() {
|
||||
}
|
||||
|
||||
public void handleException(Logger log, Throwable t, StreamObserver<?> responseObserver) {
|
||||
public void handleException(Logger log,
|
||||
Throwable t,
|
||||
StreamObserver<?> responseObserver) {
|
||||
// Log the core api error (this is last chance to do that), wrap it in a new
|
||||
// gRPC StatusRuntimeException, then send it to the client in the gRPC response.
|
||||
log.error("", t);
|
||||
|
@ -55,6 +57,17 @@ class GrpcExceptionHandler {
|
|||
throw grpcStatusRuntimeException;
|
||||
}
|
||||
|
||||
public void handleExceptionAsWarning(Logger log,
|
||||
String calledMethod,
|
||||
Throwable t,
|
||||
StreamObserver<?> responseObserver) {
|
||||
// Just log a warning instead of an error with full stack trace.
|
||||
log.warn(calledMethod + " -> " + t.getMessage());
|
||||
var grpcStatusRuntimeException = wrapException(t);
|
||||
responseObserver.onError(grpcStatusRuntimeException);
|
||||
throw grpcStatusRuntimeException;
|
||||
}
|
||||
|
||||
private StatusRuntimeException wrapException(Throwable t) {
|
||||
// We want to be careful about what kinds of exception messages we send to the
|
||||
// client. Expected core exceptions should be wrapped in an IllegalStateException
|
||||
|
|
Loading…
Add table
Reference in a new issue