Skip to content

Commit

Permalink
More exception handling edits
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed Aug 31, 2024
1 parent 6155242 commit 470b300
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class LatencyBenchmark {
client2=Convex.connect(server.getHostAddress(), VILLAIN,KPS[1]);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (Exception e) {
} catch (Throwable e) {
e.printStackTrace();
throw new Error(e);
}
Expand Down
3 changes: 2 additions & 1 deletion convex-cli/src/main/java/convex/cli/etch/EtchValidate.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import convex.etch.EtchCorruptionError;
import convex.etch.EtchStore;
import convex.etch.EtchUtils.FullValidator;
import convex.core.exceptions.*;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;

Expand Down Expand Up @@ -42,7 +43,7 @@ public void visitHash(convex.etch.Etch e, Hash h) {

Blob encoding =cell.getEncoding();
encoded+=encoding.count();
} catch (Exception e1) {
} catch (IOException | InvalidDataException e1) {
fail("Failed to validate cell "+h+" cause:" + e1);
}
}
Expand Down
8 changes: 4 additions & 4 deletions convex-cli/src/main/java/convex/cli/mixins/KeyStoreMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void saveKeyStore(char[] storePassword) {
paranoia("Trying to save keystore in strict mode with no integrity password");
}
PFXTools.saveStore(keyStore, getKeyStoreFile(), storePassword);
} catch (Exception t) {
} catch (IOException | GeneralSecurityException t) {
throw new CLIError("Failed to save keystore",t);
}
}
Expand All @@ -176,7 +176,7 @@ public void addKeyPairToStore(AKeyPair keyPair, char[] keyPassword) {
try {
// save the key in the keystore
PFXTools.setKeyPair(keyStore, keyPair, keyPassword);
} catch (Exception t) {
} catch (IOException | GeneralSecurityException t) {
throw new CLIError("Cannot store the key to the key store",t);
}

Expand Down Expand Up @@ -219,7 +219,7 @@ public AKeyPair loadKeyFromStore(String publicKey, char[] keyPassword) {
return null;
} catch (UnrecoverableKeyException t) {
throw new CLIError(ExitCodes.CONFIG,"Cannot load key from key Store - possibly incorrect password?", t);
} catch (Exception t) {
} catch (GeneralSecurityException t) {
throw new CLIError("Cannot load key from key Store", t);
}
}
Expand All @@ -242,7 +242,7 @@ public int keyCount(String pk) {
result++;
}
}
} catch (Exception t) {
} catch (GeneralSecurityException t) {
throw new CLIError("Cannot load aliases from key Store", t);
}
return result;
Expand Down
2 changes: 1 addition & 1 deletion convex-cli/src/main/java/convex/cli/peer/PeerStart.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void execute() throws InterruptedException {
} catch (ConfigException t) {
throw new CLIError(ExitCodes.CONFIG,"Error in peer configuration: "+t.getMessage(),t);
} catch (LaunchException e) {
throw new CLIError("Error in peer configuration: "+e.getMessage(),e);
throw new CLIError("Error launching peer: "+e.getMessage(),e);
} finally {
if (restServer!=null) restServer.close();
}
Expand Down
5 changes: 2 additions & 3 deletions convex-peer/src/main/java/convex/peer/AThreadedComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ public void run() {
try {
loop();
} catch (InterruptedException e) {
// Interrupted, so we are exiting
log.trace("Component thread interrupted: {}",thread);
Thread.currentThread().interrupt();
break;
} catch (Exception e) {
log.warn("Unexpected exception in "+AThreadedComponent.this.getClass().getSimpleName(),e);
}
}
}

// Finally close the component properly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private void pollBelief() throws InterruptedException {
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (Exception t) {
} catch (RuntimeException | TimeoutException | ExecutionException | IOException t) {
if (server.isLive()) {
log.warn("Belief Polling failed: {}",t.getClass().toString()+" : "+t.getMessage());
}
Expand Down
2 changes: 1 addition & 1 deletion convex-peer/src/main/java/convex/peer/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ protected void handleDataRequest(Message m) {
}
} catch (BadFormatException e) {
log.warn("Unable to deliver missing data due badly formatted DATA_REQUEST: {}", m);
} catch (Exception e) {
} catch (RuntimeException e) {
log.warn("Unable to deliver missing data due to exception:", e);
}
}
Expand Down

0 comments on commit 470b300

Please sign in to comment.