Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closing discord spams log #1

Open
kevinthegreat1 opened this issue Nov 23, 2023 · 0 comments
Open

Closing discord spams log #1

kevinthegreat1 opened this issue Nov 23, 2023 · 0 comments

Comments

@kevinthegreat1
Copy link

kevinthegreat1 commented Nov 23, 2023

If discord is closed while discord ipc is connected, DiscordIPC.isConnected() will still return true but setActivity() will fail and log the message with the following code. Users have no way of knowing if setActivity() failed or not. Instead of just printing the error, this should throw and let users handle the error.

@Override
protected void write(ByteBuffer buffer) {
try {
sc.write(buffer);
} catch (IOException e) {
e.printStackTrace();
}
}

@Override
protected void write(ByteBuffer buffer) {
try {
raf.write(buffer.array());
} catch (IOException e) {
e.printStackTrace();
}
}

Potential Fix

Catch the error, stop the connection, and throw the error up. This stops the connection properly and also lets users handle the error. This also allows users to have custom logging methods instead of just printStackTrace.

protected void write(ByteBuffer buffer) throws IOException {
        try {
            sc.write(buffer);
        } catch (IOException e) {
            DiscordIPC.stop();
            throw e;
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant