Skip to content

Commit

Permalink
Exclude SocketException from print networking errors setting
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Sep 8, 2024
1 parent 8bf9593 commit ea00d1c
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,18 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.net.SocketException;

@Mixin(ClientConnection.class)
public abstract class MixinClientConnection {

@Inject(method = "exceptionCaught", at = @At("HEAD"))
private void printNetworkingErrors(ChannelHandlerContext context, Throwable ex, CallbackInfo ci) {
if (DebugSettings.global().printNetworkingErrorsToLogs.getValue()) {
if (ex instanceof SocketException) {
// Thrown when server is not reachable
return;
}
ViaFabricPlus.global().getLogger().error("An exception occurred while handling a packet", ex);
}
}
Expand Down

0 comments on commit ea00d1c

Please sign in to comment.