Skip to content
This repository was archived by the owner on Apr 9, 2023. It is now read-only.
This repository was archived by the owner on Apr 9, 2023. It is now read-only.

Try / catch ignored? #39

@aekramer

Description

@aekramer

Hi, first off thank you for this amazing rpc :)

But I have seem to encountered an issue, when people launch a second instance of the application, it will throw an error process already in use (this also happens if discord rpc is in use by something else right now).
No issues there, but it throws a FileNotFoundException which I attempted to catch to neatly print that the RPC is disabled opposed to the stacktrace, and also disable usage for it later down the road.
java.io.FileNotFoundException: C:\Users\Alex\AppData\Local\Temp\discord-rpc\discord-rpc.dll (The process cannot access the file because it is being used by another process) at java.io.FileOutputStream.open0(Native Method) at java.io.FileOutputStream.open(Unknown Source) at java.io.FileOutputStream.<init>(Unknown Source) at java.io.FileOutputStream.<init>(Unknown Source) at net.arikia.dev.drpc.DiscordRPC.openOutputStream(DiscordRPC.java:186) at net.arikia.dev.drpc.DiscordRPC.loadDLL(DiscordRPC.java:152) at net.arikia.dev.drpc.DiscordRPC.<clinit>(DiscordRPC.java:21) at com.runescape.Client.main(Client.java:4126)

Ive tried using a normal Try/Catch for FileNotFoundException but then Eclipse will tell me that this code will never throw this exception (except it already did), so instead I setup a general Exception clause, which seems completely ignored (the error message is never printed)

`try {
DiscordEventHandlers handlers = new DiscordEventHandlers();
DiscordRPC.discordInitialize("123", handlers, true);

				DiscordRichPresence rich = new DiscordRichPresence.Builder("At login screen").build();
				DiscordRPC.discordUpdatePresence(rich);
				
				Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
				    @Override
				    public void run() {
				    	DiscordRPC.discordShutdown();
				    }
				}));
			} catch (Exception e) {
				System.out.println("Failed connecting to discord: "+ e.getClass());
			}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions