Skip to content
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.uid2</groupId>
<artifactId>uid2-operator</artifactId>
<version>5.56.58</version>
<version>5.56.42-alpha-200-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
16 changes: 13 additions & 3 deletions src/main/java/com/uid2/operator/vertx/GenericFailureHandler.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
}
}

Expand Down