Less error message spam in debug mode

This commit is contained in:
Anuken 2024-10-14 00:36:00 -04:00
parent 4b78e65d7f
commit c07061e94f

View File

@ -42,7 +42,12 @@ public class ArcNetProvider implements NetProvider{
public ArcNetProvider(){
ArcNet.errorHandler = e -> {
if(Log.level == LogLevel.debug){
Log.debug(Strings.getStackTrace(e));
var finalCause = Strings.getFinalCause(e);
//"connection is closed" is a pointless annoying error that should not be logged
if(!"Connection is closed.".equals(finalCause.getMessage())){
Log.debug(Strings.getStackTrace(e));
}
}
};
@ -361,10 +366,12 @@ public class ArcNetProvider implements NetProvider{
@Override
public void send(Object object, boolean reliable){
try{
if(reliable){
connection.sendTCP(object);
}else{
connection.sendUDP(object);
if(connection.isConnected()){
if(reliable){
connection.sendTCP(object);
}else{
connection.sendUDP(object);
}
}
}catch(Exception e){
Log.err(e);