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
@@ -42,8 +42,13 @@ public class ArcNetProvider implements NetProvider{
public ArcNetProvider(){ public ArcNetProvider(){
ArcNet.errorHandler = e -> { ArcNet.errorHandler = e -> {
if(Log.level == LogLevel.debug){ if(Log.level == LogLevel.debug){
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)); Log.debug(Strings.getStackTrace(e));
} }
}
}; };
//fetch this in the main thread to prevent threading issues //fetch this in the main thread to prevent threading issues
@@ -361,11 +366,13 @@ public class ArcNetProvider implements NetProvider{
@Override @Override
public void send(Object object, boolean reliable){ public void send(Object object, boolean reliable){
try{ try{
if(connection.isConnected()){
if(reliable){ if(reliable){
connection.sendTCP(object); connection.sendTCP(object);
}else{ }else{
connection.sendUDP(object); connection.sendUDP(object);
} }
}
}catch(Exception e){ }catch(Exception e){
Log.err(e); Log.err(e);
Log.info("Error sending packet. Disconnecting invalid client!"); Log.info("Error sending packet. Disconnecting invalid client!");