diff --git a/convex-benchmarks/src/main/java/convex/benchmarks/LatencyBenchmark.java b/convex-benchmarks/src/main/java/convex/benchmarks/LatencyBenchmark.java index cc46e3974..804a2efb1 100644 --- a/convex-benchmarks/src/main/java/convex/benchmarks/LatencyBenchmark.java +++ b/convex-benchmarks/src/main/java/convex/benchmarks/LatencyBenchmark.java @@ -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); } diff --git a/convex-cli/src/main/java/convex/cli/etch/EtchValidate.java b/convex-cli/src/main/java/convex/cli/etch/EtchValidate.java index fabf64dc8..8430ffd16 100644 --- a/convex-cli/src/main/java/convex/cli/etch/EtchValidate.java +++ b/convex-cli/src/main/java/convex/cli/etch/EtchValidate.java @@ -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; @@ -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); } } diff --git a/convex-cli/src/main/java/convex/cli/mixins/KeyStoreMixin.java b/convex-cli/src/main/java/convex/cli/mixins/KeyStoreMixin.java index 436ddd628..5b71c31f5 100644 --- a/convex-cli/src/main/java/convex/cli/mixins/KeyStoreMixin.java +++ b/convex-cli/src/main/java/convex/cli/mixins/KeyStoreMixin.java @@ -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); } } @@ -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); } @@ -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); } } @@ -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; diff --git a/convex-cli/src/main/java/convex/cli/peer/PeerStart.java b/convex-cli/src/main/java/convex/cli/peer/PeerStart.java index 785c31f43..5eb51dc8b 100644 --- a/convex-cli/src/main/java/convex/cli/peer/PeerStart.java +++ b/convex-cli/src/main/java/convex/cli/peer/PeerStart.java @@ -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(); } diff --git a/convex-peer/src/main/java/convex/peer/AThreadedComponent.java b/convex-peer/src/main/java/convex/peer/AThreadedComponent.java index e0a85b144..584b65da8 100644 --- a/convex-peer/src/main/java/convex/peer/AThreadedComponent.java +++ b/convex-peer/src/main/java/convex/peer/AThreadedComponent.java @@ -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 diff --git a/convex-peer/src/main/java/convex/peer/ConnectionManager.java b/convex-peer/src/main/java/convex/peer/ConnectionManager.java index ab51aee26..26f687bfb 100644 --- a/convex-peer/src/main/java/convex/peer/ConnectionManager.java +++ b/convex-peer/src/main/java/convex/peer/ConnectionManager.java @@ -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()); } diff --git a/convex-peer/src/main/java/convex/peer/Server.java b/convex-peer/src/main/java/convex/peer/Server.java index 2d9306eb4..9bcf38d08 100644 --- a/convex-peer/src/main/java/convex/peer/Server.java +++ b/convex-peer/src/main/java/convex/peer/Server.java @@ -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); } }