public void handleError(Client source, Throwable t) {

        if (networkClient != null && !networkClient.isConnected()) {
            System.err.println("CLIENT: network error. Connection is closed");
        } else {
            System.err.println("NETWORK ERROR: " + t.getMessage());

            if (t instanceof ConnectException) {
                if (connected) {
                    close();
                    System.out.println("Server shut down.");
                }
            } else {
                t.printStackTrace();
            }
        }

    }