mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-22 22:45:21 +01:00
Use the logger of the gRPC service throwing an exception
This commit is contained in:
parent
e2bb64de7d
commit
e5291e9f45
11 changed files with 44 additions and 40 deletions
|
@ -45,7 +45,7 @@ class GrpcDisputeAgentsService extends DisputeAgentsGrpc.DisputeAgentsImplBase {
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import javax.inject.Singleton;
|
|||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import static io.grpc.Status.INVALID_ARGUMENT;
|
||||
import static io.grpc.Status.UNKNOWN;
|
||||
|
@ -37,7 +37,6 @@ import static io.grpc.Status.UNKNOWN;
|
|||
* An unexpected Throwable's message will be replaced with an 'unexpected' error message.
|
||||
*/
|
||||
@Singleton
|
||||
@Slf4j
|
||||
class GrpcExceptionHandler {
|
||||
|
||||
private final Predicate<Throwable> isExpectedException = (t) ->
|
||||
|
@ -47,7 +46,7 @@ class GrpcExceptionHandler {
|
|||
public GrpcExceptionHandler() {
|
||||
}
|
||||
|
||||
public void handleException(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);
|
||||
|
|
|
@ -16,6 +16,8 @@ import java.util.HashMap;
|
|||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import static bisq.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
|
@ -24,6 +26,7 @@ import static java.util.concurrent.TimeUnit.SECONDS;
|
|||
import bisq.daemon.grpc.interceptor.CallRateMeteringInterceptor;
|
||||
import bisq.daemon.grpc.interceptor.GrpcCallRateMeter;
|
||||
|
||||
@Slf4j
|
||||
class GrpcGetTradeStatisticsService extends GetTradeStatisticsGrpc.GetTradeStatisticsImplBase {
|
||||
|
||||
private final CoreApi coreApi;
|
||||
|
@ -47,7 +50,7 @@ class GrpcGetTradeStatisticsService extends GetTradeStatisticsGrpc.GetTradeStati
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ class GrpcHelpService extends HelpGrpc.HelpImplBase {
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ class GrpcOffersService extends OffersGrpc.OffersImplBase {
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ class GrpcOffersService extends OffersGrpc.OffersImplBase {
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ class GrpcOffersService extends OffersGrpc.OffersImplBase {
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ class GrpcOffersService extends OffersGrpc.OffersImplBase {
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ class GrpcOffersService extends OffersGrpc.OffersImplBase {
|
|||
responseObserver.onCompleted();
|
||||
});
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ class GrpcOffersService extends OffersGrpc.OffersImplBase {
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@ import java.util.HashMap;
|
|||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import static bisq.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor;
|
||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
@ -49,7 +51,7 @@ import static java.util.concurrent.TimeUnit.SECONDS;
|
|||
import bisq.daemon.grpc.interceptor.CallRateMeteringInterceptor;
|
||||
import bisq.daemon.grpc.interceptor.GrpcCallRateMeter;
|
||||
|
||||
|
||||
@Slf4j
|
||||
class GrpcPaymentAccountsService extends PaymentAccountsGrpc.PaymentAccountsImplBase {
|
||||
|
||||
private final CoreApi coreApi;
|
||||
|
@ -72,7 +74,7 @@ class GrpcPaymentAccountsService extends PaymentAccountsGrpc.PaymentAccountsImpl
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +90,7 @@ class GrpcPaymentAccountsService extends PaymentAccountsGrpc.PaymentAccountsImpl
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +106,7 @@ class GrpcPaymentAccountsService extends PaymentAccountsGrpc.PaymentAccountsImpl
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,7 +121,7 @@ class GrpcPaymentAccountsService extends PaymentAccountsGrpc.PaymentAccountsImpl
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ class GrpcPriceService extends PriceGrpc.PriceImplBase {
|
|||
responseObserver.onCompleted();
|
||||
});
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ class GrpcShutdownService extends ShutdownServerGrpc.ShutdownServerImplBase {
|
|||
responseObserver.onCompleted();
|
||||
UserThread.runAfter(BisqHeadlessApp.getShutDownHandler(), 500, MILLISECONDS);
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ class GrpcTradesService extends TradesGrpc.TradesImplBase {
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ class GrpcTradesService extends TradesGrpc.TradesImplBase {
|
|||
responseObserver.onCompleted();
|
||||
});
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ class GrpcTradesService extends TradesGrpc.TradesImplBase {
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ class GrpcTradesService extends TradesGrpc.TradesImplBase {
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ class GrpcTradesService extends TradesGrpc.TradesImplBase {
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ class GrpcTradesService extends TradesGrpc.TradesImplBase {
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public class GrpcVersionService extends GetVersionGrpc.GetVersionImplBase {
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ class GrpcWalletsService extends WalletsGrpc.WalletsImplBase {
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ class GrpcWalletsService extends WalletsGrpc.WalletsImplBase {
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ class GrpcWalletsService extends WalletsGrpc.WalletsImplBase {
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ class GrpcWalletsService extends WalletsGrpc.WalletsImplBase {
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ class GrpcWalletsService extends WalletsGrpc.WalletsImplBase {
|
|||
}
|
||||
});
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ class GrpcWalletsService extends WalletsGrpc.WalletsImplBase {
|
|||
}
|
||||
});
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ class GrpcWalletsService extends WalletsGrpc.WalletsImplBase {
|
|||
responseObserver.onCompleted();
|
||||
});
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,7 @@ class GrpcWalletsService extends WalletsGrpc.WalletsImplBase {
|
|||
responseObserver.onCompleted();
|
||||
});
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -271,7 +271,7 @@ class GrpcWalletsService extends WalletsGrpc.WalletsImplBase {
|
|||
responseObserver.onCompleted();
|
||||
});
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -286,7 +286,7 @@ class GrpcWalletsService extends WalletsGrpc.WalletsImplBase {
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ class GrpcWalletsService extends WalletsGrpc.WalletsImplBase {
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -312,7 +312,7 @@ class GrpcWalletsService extends WalletsGrpc.WalletsImplBase {
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -325,7 +325,7 @@ class GrpcWalletsService extends WalletsGrpc.WalletsImplBase {
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -338,7 +338,7 @@ class GrpcWalletsService extends WalletsGrpc.WalletsImplBase {
|
|||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(cause, responseObserver);
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue