From 8b6d16b1557080ab7e629814033494db47c337bf Mon Sep 17 00:00:00 2001 From: Andrew Ash Date: Thu, 9 Feb 2023 22:48:37 -0800 Subject: [PATCH 1/2] Distinguish error logging between thrown Errors and ServiceExceptions --- .../conjure/java/undertow/runtime/ConjureExceptions.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conjure-java-undertow-runtime/src/main/java/com/palantir/conjure/java/undertow/runtime/ConjureExceptions.java b/conjure-java-undertow-runtime/src/main/java/com/palantir/conjure/java/undertow/runtime/ConjureExceptions.java index e38f9e454..d620b8146 100644 --- a/conjure-java-undertow-runtime/src/main/java/com/palantir/conjure/java/undertow/runtime/ConjureExceptions.java +++ b/conjure-java-undertow-runtime/src/main/java/com/palantir/conjure/java/undertow/runtime/ConjureExceptions.java @@ -176,7 +176,7 @@ private static void frameworkException(HttpServerExchange exchange, FrameworkExc private static void error(HttpServerExchange exchange, Error error) { // log errors in order to associate the log line with the correct traceId but // avoid doing work beyond setting a 500 response code, no response body is sent. - log.error("Error handling request", error); + log.error("Error thrown while handling request", error); // The writeResponse method terminates responses if data has already been sent to clients // do not interpret partial data as a full response. writeResponse(exchange, Optional.empty(), ErrorType.INTERNAL.httpErrorCode()); @@ -220,13 +220,13 @@ private static boolean isResponseStarted(HttpServerExchange exchange) { private static void log(ServiceException serviceException, Throwable exceptionForLogging) { if (serviceException.getErrorType().httpErrorCode() / 100 == 4 /* client error */) { log.info( - "Error handling request", + "ServiceException thrown while handling request", SafeArg.of("errorInstanceId", serviceException.getErrorInstanceId()), SafeArg.of("errorName", serviceException.getErrorType().name()), exceptionForLogging); } else { log.error( - "Error handling request", + "ServiceException thrown while handling request", SafeArg.of("errorInstanceId", serviceException.getErrorInstanceId()), SafeArg.of("errorName", serviceException.getErrorType().name()), exceptionForLogging); From a5e01af0479b37f4c425ee42f610cd2b7e32784d Mon Sep 17 00:00:00 2001 From: svc-changelog Date: Fri, 10 Feb 2023 06:54:26 +0000 Subject: [PATCH 2/2] Add generated changelog entries --- changelog/@unreleased/pr-1955.v2.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelog/@unreleased/pr-1955.v2.yml diff --git a/changelog/@unreleased/pr-1955.v2.yml b/changelog/@unreleased/pr-1955.v2.yml new file mode 100644 index 000000000..bb0c08373 --- /dev/null +++ b/changelog/@unreleased/pr-1955.v2.yml @@ -0,0 +1,5 @@ +type: improvement +improvement: + description: Distinguish error logging between thrown Errors and ServiceExceptions + links: + - https://github.com/palantir/conjure-java/pull/1955