Skip to content

Commit

Permalink
Fix exception handling during Tor setup
Browse files Browse the repository at this point in the history
A recent change in the netlayer is now seeing exceptions wrapped in
a TorCtlException if an error occurs while setting up Tor.

So when an issue such as "Auth cookie not created" (bisq-network#2398) occurs,
which was previously raised as an IOException, it was restarting Tor
rather than showing the error message to the user.
  • Loading branch information
devinbileck committed Mar 14, 2019
1 parent cdce61c commit 8ccbe9e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions p2p/src/main/java/bisq/network/p2p/network/TorNetworkNode.java
Expand Up @@ -282,10 +282,18 @@ public void run() {
});
log.info("It will take some time for the HS to be reachable (~40 seconds). You will be notified about this");
} catch (TorCtlException e) {
log.error("Tor node creation failed: " + (e.getCause() != null ? e.getCause().toString() : e.toString()));
restartTor(e.getMessage());
String msg = e.getCause() != null ? e.getCause().toString() : e.toString();
log.error("Tor node creation failed: {}", msg);
if (e.getCause() instanceof IOException) {
// Since we cannot connect to Tor, we cannot do nothing.
// Furthermore, we have no hidden services started yet, so there is no graceful
// shutdown needed either
UserThread.execute(() -> setupListeners.forEach(s -> s.onSetupFailed(new RuntimeException(msg))));
} else {
restartTor(e.getMessage());
}
} catch (IOException e) {
log.error("Could not connect to running Tor: " + e.getMessage());
log.error("Could not connect to running Tor: {}", e.getMessage());
// Since we cannot connect to Tor, we cannot do nothing.
// Furthermore, we have no hidden services started yet, so there is no graceful
// shutdown needed either
Expand Down

0 comments on commit 8ccbe9e

Please sign in to comment.