3
0
Fork 0

FIX: logging issue for socket errors

This commit is contained in:
Thomas van Weert 2023-02-16 18:08:01 +01:00
parent 85c0374628
commit 29e890c022

View file

@ -12,6 +12,8 @@ import nl.iobyte.themeparkconnector.api.state.states.ConnectedState;
import nl.iobyte.themeparkconnector.api.state.states.IdleState; import nl.iobyte.themeparkconnector.api.state.states.IdleState;
import nl.iobyte.themeparkconnector.logger.ThemeParkConnectorLogger; import nl.iobyte.themeparkconnector.logger.ThemeParkConnectorLogger;
import java.util.Arrays;
public class SystemDriver extends SocketDriver { public class SystemDriver extends SocketDriver {
/** /**
@ -60,10 +62,22 @@ public class SystemDriver extends SocketDriver {
api.getStateService().setState(new IdleState("Socket connection error")); api.getStateService().setState(new IdleState("Socket connection error"));
api.getPlayerStateService().stop(); api.getPlayerStateService().stop();
ThemeParkConnectorLogger.toConsole(ThemeParkConnector.getGson().toJson(args)); Arrays.stream(args).filter(arg -> {
if(!(arg instanceof Throwable))
return false;
((Throwable) arg).printStackTrace();
return false;
}).forEach(arg -> ThemeParkConnectorLogger.toConsole(ThemeParkConnector.getGson().toJson(arg)));
}); });
socket.on(Manager.EVENT_ERROR, args -> ThemeParkConnectorLogger.toConsole(ThemeParkConnector.getGson().toJson(args))); socket.on(Manager.EVENT_ERROR, args -> Arrays.stream(args).filter(arg -> {
if(!(arg instanceof Throwable))
return false;
((Throwable) arg).printStackTrace();
return false;
}).forEach(arg -> ThemeParkConnectorLogger.toConsole(ThemeParkConnector.getGson().toJson(arg))));
} }
/** /**