From 5364d5bf3af4a7a1b792e44aacb666b2a4106344 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta <87213665+tatu-at-datastax@users.noreply.github.com> Date: Wed, 26 Jul 2023 11:12:22 -0700 Subject: [PATCH] Reduce logging of known+handled cases (#472) --- .../jsonapi/service/processor/CommandProcessor.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/processor/CommandProcessor.java b/src/main/java/io/stargate/sgv2/jsonapi/service/processor/CommandProcessor.java index cb3d87b757..d2515ae8c5 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/processor/CommandProcessor.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/processor/CommandProcessor.java @@ -62,19 +62,21 @@ public Uni processCommand( return operation.execute(queryExecutor); }) - // handler failures here + // handle failures here .onFailure() .recoverWithItem( t -> { - logger.warn( - "The command {} failed with exception", command.getClass().getSimpleName(), t); // DocsException is supplier of the CommandResult // so simply return if (t instanceof JsonApiException jsonApiException) { + // Note: JsonApiException means that JSON API itself handled the situation + // (created, or wrapped the exception) -- should not be logged (have already + // been logged if necessary) return jsonApiException; } - - // otherwise use generic for now + // But other exception types are unexpected, so log for now + logger.warn( + "Command '{}' failed with exception", command.getClass().getSimpleName(), t); return new ThrowableCommandResultSupplier(t); })