[Minor] Clean up code

This commit is contained in:
Robert von Burg 2023-04-06 14:33:32 +02:00
parent f55780ffb4
commit 601ff098fc
Signed by: eitch
GPG Key ID: 75DB9C85C74331F7
1 changed files with 6 additions and 4 deletions

View File

@ -11,6 +11,7 @@ import jakarta.websocket.CloseReason;
import jakarta.websocket.EndpointConfig;
import jakarta.websocket.MessageHandler;
import jakarta.websocket.Session;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@ -167,11 +168,12 @@ public class WebSocketClient implements MessageHandler.Whole<String> {
}
logger.info("User " + this.certificate.getUsername() + " authenticated on WebSocket with remote IP "
+ this.remoteIp);
} catch (StrolchNotAuthenticatedException e) {
logger.error("Failed to authenticate user " + username + ": " + e.getMessage());
close(CloseReason.CloseCodes.UNEXPECTED_CONDITION, "Invalid authentication");
return;
} catch (Exception e) {
if (e instanceof StrolchNotAuthenticatedException)
logger.error("Failed to authenticate user " + username + ": " + e.getMessage());
else
logger.error("Failed to authenticate user " + username, e);
logger.error("Failed to authenticate user " + username, e);
close(CloseReason.CloseCodes.UNEXPECTED_CONDITION, "Invalid authentication");
return;
}