Skip to content

Commit

Permalink
Move broken pipe exception handling
Browse files Browse the repository at this point in the history
If it's somehow not actually triggered in close(), the more invasive message is beneficial. send*() methods should be consistent in exception handling anyways.
  • Loading branch information
Eiim committed Oct 29, 2024
1 parent c1dde0f commit cf11e7d
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/main/java/chokistream/ChirunoModClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,7 @@ public void sendInit() throws IOException {

public void sendDisconnect() throws IOException {
logger.log("Sending disconnect packet", LogLevel.VERBOSE);
try {
out.write((new Packet((byte)0x03, (byte)0x00, new byte[] {})).pack);
} catch (SocketException e) {
/**
* Refer to docs.
* https://github.com/Eiim/Chokistream/wiki/Technical-info-on-bugs-and-quirks/_edit#issues-with-luma3ds-control-wireless-connection-hack
* todo: investigate */
if(e.getMessage().contains("Broken pipe")) {
// do something?
}

logger.log("ChirunoModClient.sendDisconnect() warning: "+e.getClass()+": "+e.getMessage());
logger.log(Arrays.toString(e.getStackTrace()), LogLevel.VERBOSE);
logger.log("The 3DS seems to have already disconnected");
}
out.write((new Packet((byte)0x03, (byte)0x00, new byte[] {})).pack);
}

// We don't really have a use for this yet but might as well support it
Expand Down Expand Up @@ -221,7 +207,21 @@ public void switchScreen() throws IOException {

@Override
public void close() throws IOException {
sendDisconnect();
try {
sendDisconnect();
} catch (SocketException e) {
if(e.getMessage().contains("Broken pipe")) {
/*
* Documented here: https://github.com/Eiim/Chokistream/wiki/Technical-info-on-bugs-and-quirks/_edit#issues-with-luma3ds-control-wireless-connection-hack
* TODO: investigate, possibly handle more cleanly or fix
*/
logger.log("ChirunoModClient.close() warning: "+e.getClass()+": "+e.getMessage());
logger.log(Arrays.toString(e.getStackTrace()), LogLevel.VERBOSE);
logger.log("The 3DS seems to have already disconnected");
} else {
throw e;
}
}
in.close();
out.close();
client.close();
Expand Down

0 comments on commit cf11e7d

Please sign in to comment.