From ea979fa027becaae562bb10282be2161db09463a Mon Sep 17 00:00:00 2001 From: Enrico Joerns Date: Thu, 10 Apr 2014 19:00:24 +0200 Subject: [PATCH] [cooja] plugins/Visualizer: Use more specific catches and multi-catches if possible --- .../contikios/cooja/plugins/Visualizer.java | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/tools/cooja/java/org/contikios/cooja/plugins/Visualizer.java b/tools/cooja/java/org/contikios/cooja/plugins/Visualizer.java index b49d12d79..45654955f 100644 --- a/tools/cooja/java/org/contikios/cooja/plugins/Visualizer.java +++ b/tools/cooja/java/org/contikios/cooja/plugins/Visualizer.java @@ -527,7 +527,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp { } file = list.get(0); } - catch (Exception e) { + catch (UnsupportedFlavorException | IOException e) { return; } @@ -564,9 +564,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp { return false; } file = list.get(0); - } catch (UnsupportedFlavorException e) { - return false; - } catch (IOException e) { + } catch (UnsupportedFlavorException | IOException e) { return false; } @@ -603,9 +601,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp { VisualizerSkin newSkin = skinClass.newInstance(); newSkin.setActive(Visualizer.this.simulation, Visualizer.this); currentSkins.add(0, newSkin); - } catch (InstantiationException e1) { - e1.printStackTrace(); - } catch (IllegalAccessException e1) { + } catch (InstantiationException | IllegalAccessException e1) { e1.printStackTrace(); } repaint(); @@ -707,9 +703,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp { }); menu.add(menuItem); } - } catch (InstantiationException e1) { - logger.fatal("Error: " + e1.getMessage(), e1); - } catch (IllegalAccessException e1) { + } catch (InstantiationException | IllegalAccessException e1) { logger.fatal("Error: " + e1.getMessage(), e1); } } @@ -731,9 +725,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp { }); menu.add(menuItem); } - } catch (InstantiationException e1) { - logger.fatal("Error: " + e1.getMessage(), e1); - } catch (IllegalAccessException e1) { + } catch (InstantiationException | IllegalAccessException e1) { logger.fatal("Error: " + e1.getMessage(), e1); } } @@ -1483,7 +1475,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp { Double.parseDouble(matrix[5]) ); resetViewport = 0; - } catch (Exception e) { + } catch (NumberFormatException e) { logger.warn("Bad viewport: " + e.getMessage()); resetViewport(); }