Log 'trade not found' a warning instead of full stack trace

This commit is contained in:
ghubstan 2021-02-27 17:25:49 -03:00
parent e5a0a3998d
commit 320e63c0a1
No known key found for this signature in database
GPG key ID: E35592D6800A861E
2 changed files with 7 additions and 3 deletions

View file

@ -58,9 +58,9 @@ class GrpcExceptionHandler {
}
public void handleExceptionAsWarning(Logger log,
String calledMethod,
Throwable t,
StreamObserver<?> responseObserver) {
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);

View file

@ -78,6 +78,10 @@ class GrpcTradesService extends TradesGrpc.TradesImplBase {
.build();
responseObserver.onNext(reply);
responseObserver.onCompleted();
} catch (IllegalArgumentException cause) {
// Offer makers may call 'gettrade' many times before a trade exists.
// Log a 'trade not found' warning instead of a full stack trace.
exceptionHandler.handleExceptionAsWarning(log, "getTrade", cause, responseObserver);
} catch (Throwable cause) {
exceptionHandler.handleException(log, cause, responseObserver);
}