diff --git a/pom.xml b/pom.xml index b754792d9..4bf985226 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.uid2 uid2-operator - 5.56.58 + 5.56.42-alpha-200-SNAPSHOT UTF-8 diff --git a/src/main/java/com/uid2/operator/vertx/GenericFailureHandler.java b/src/main/java/com/uid2/operator/vertx/GenericFailureHandler.java index 855ea1187..caa1b886e 100644 --- a/src/main/java/com/uid2/operator/vertx/GenericFailureHandler.java +++ b/src/main/java/com/uid2/operator/vertx/GenericFailureHandler.java @@ -1,5 +1,9 @@ package com.uid2.operator.vertx; +import com.uid2.shared.auth.IAuthorizable; +import com.uid2.shared.auth.OperatorKey; +import com.uid2.shared.middleware.AuthMiddleware; +import com.uid2.shared.auth.ClientKey; import io.vertx.core.Handler; import io.vertx.core.http.HttpClosedException; import io.vertx.core.http.HttpServerResponse; @@ -19,16 +23,22 @@ public void handle(RoutingContext ctx) { String url = ctx.normalizedPath(); Throwable t = ctx.failure(); + String contact = "unknown"; + final ClientKey clientKey = (ClientKey) AuthMiddleware.getAuthClient(ctx); + if (clientKey != null) { + contact = clientKey.getContact(); + } + if (t != null) { // Because Vert.x swallows stack traces so cannot log stack trace // And we want to ignore HttpClosedException errors as it is (usually) caused by users and no impact if (t instanceof HttpClosedException) { - LOGGER.warn("Ignoring exception - URL: [{}] - Error:", url, t); + LOGGER.warn("Ignoring exception - URL: [{}], Participant: [{}] - Error:", url, contact, t); response.end(); } else if (statusCode >= 500 && statusCode < 600) { // 5xx is server error, so error - LOGGER.error("URL: [{}] - Error response code: [{}] - Error:", url, statusCode, t); + LOGGER.error("URL: [{}], Participant: [{}] - Error response code: [{}] - Error:", url, contact, statusCode, t); } else if (statusCode >= 400 && statusCode < 500) { // 4xx is user error, so just warn - LOGGER.warn("URL: [{}] - Error response code: [{}] - Error:", url, statusCode, t); + LOGGER.warn("URL: [{}], Participant: [{}] - Error response code: [{}] - Error:", url, contact, statusCode, t); } }