Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distinguish error logging between thrown Errors and ServiceExceptions #1955

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-1955.v2.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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);
Expand Down