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 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);