Skip to content

Closing discord spams log #1

Open
@kevinthegreat1

Description

@kevinthegreat1

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;
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions