Skip to content

Commit

Permalink
[Change] Adjusted some error messages
Browse files Browse the repository at this point in the history
- Adjusted the `WindowsPipe` to throw a proper `RuntimeException` in cases where we are unable to write to a IPC pipe (There is a difference from `exists` to `can read/write`)
  - A commit awhile ago broke the prior behavior, allowing the Pipe to be written to, causing another exception later. This change lets it fail more safely and as expected
- Clarified the error message for when an `IOException` is thrown for the Mac/Unix pipes
  - Its a bit vague since it triggers under almost any type of operation failure
- Replaced a `printStackTrace` call in `IPCClient#connect` for autoRegister behavior, so it'll now use the logger for the `debugMode` version
- Clarified error message for if the `WinRegistry` constructor fails
  • Loading branch information
CDAGaming committed May 27, 2024
1 parent 2646f3e commit 5a3ed2f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/jagrosh/discordipc/IPCClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public void connect(DiscordBuild... preferredOrder) throws NoDiscordClientExcept
this.registerApp(getApplicationId(), null);
} catch (Throwable ex) {
if (debugMode) {
ex.printStackTrace();
getCurrentLogger(LOGGER).error("Unable to register application", ex);
} else {
getCurrentLogger(LOGGER).error("Unable to register application, enable debug mode for trace...");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private static Pipe createPipe(IPCClient ipcClient, HashMap<String, Callback> ca
try {
return osName.contains("mac") ? new MacPipe(ipcClient, callbacks, location) : new UnixPipe(ipcClient, callbacks, location);
} catch (IOException e) {
throw new RuntimeException(e);
throw new RuntimeException("Unable to create MacOS/Unix Pipe", e);
}
} else {
throw new RuntimeException("Unsupported OS: " + osName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class WindowsPipe extends Pipe {
try {
this.file = new RandomAccessFile(location, "rw");
} catch (FileNotFoundException e) {
this.file = null;
throw new RuntimeException("Unable to access '" + location + "', check file permissions", e);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jagrosh/discordipc/impl/WinRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class WinRegistry {
"WindowsRegDeleteKey", (javaSpec >= 11 ? long.class : int.class),
byte[].class);
} catch (Exception e) {
throw new RuntimeException(e);
throw new RuntimeException("Unable to setup registry data", e);
}
}

Expand Down

0 comments on commit 5a3ed2f

Please sign in to comment.