Changeset 10212 in josm for trunk/src


Ignore:
Timestamp:
2016-05-15T00:51:10+02:00 (8 years ago)
Author:
Don-vip
Message:

sonar - squid:S2221 - "Exception" should not be caught when not required by called methods

Location:
trunk/src/org/openstreetmap/josm
Files:
104 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/Main.java

    r10208 r10212  
    3535import java.util.StringTokenizer;
    3636import java.util.concurrent.Callable;
     37import java.util.concurrent.ExecutionException;
    3738import java.util.concurrent.ExecutorService;
    3839import java.util.concurrent.Executors;
     
    106107import org.openstreetmap.josm.io.OnlineResource;
    107108import org.openstreetmap.josm.io.OsmApi;
     109import org.openstreetmap.josm.io.OsmApiInitializationException;
     110import org.openstreetmap.josm.io.OsmTransferCanceledException;
    108111import org.openstreetmap.josm.plugins.PluginHandler;
    109112import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    594597                try {
    595598                    OsmApi.getOsmApi().initialize(null, true);
    596                 } catch (Exception e) {
     599                } catch (OsmTransferCanceledException | OsmApiInitializationException e) {
    597600                    Main.warn(getErrorMessage(Utils.getRootCause(e)));
    598601                }
     
    640643            }
    641644            service.shutdown();
    642         } catch (Exception ex) {
     645        } catch (InterruptedException | ExecutionException ex) {
    643646            throw new RuntimeException(ex);
    644647        }
     
    933936        ProjectionPreference.setProjection();
    934937
     938        String defaultlaf = platform.getDefaultStyle();
     939        String laf = Main.pref.get("laf", defaultlaf);
    935940        try {
    936             String defaultlaf = platform.getDefaultStyle();
    937             String laf = Main.pref.get("laf", defaultlaf);
    938             try {
    939                 UIManager.setLookAndFeel(laf);
    940             } catch (final NoClassDefFoundError | ClassNotFoundException e) {
    941                 // Try to find look and feel in plugin classloaders
    942                 Class<?> klass = null;
    943                 for (ClassLoader cl : PluginHandler.getResourceClassLoaders()) {
    944                     try {
    945                         klass = cl.loadClass(laf);
    946                         break;
    947                     } catch (ClassNotFoundException ex) {
    948                         // Do nothing
    949                         if (Main.isTraceEnabled()) {
    950                             Main.trace(ex.getMessage());
    951                         }
     941            UIManager.setLookAndFeel(laf);
     942        } catch (final NoClassDefFoundError | ClassNotFoundException e) {
     943            // Try to find look and feel in plugin classloaders
     944            Class<?> klass = null;
     945            for (ClassLoader cl : PluginHandler.getResourceClassLoaders()) {
     946                try {
     947                    klass = cl.loadClass(laf);
     948                    break;
     949                } catch (ClassNotFoundException ex) {
     950                    if (Main.isTraceEnabled()) {
     951                        Main.trace(ex.getMessage());
    952952                    }
    953953                }
    954                 if (klass != null && LookAndFeel.class.isAssignableFrom(klass)) {
    955                     try {
    956                         UIManager.setLookAndFeel((LookAndFeel) klass.getConstructor().newInstance());
    957                     } catch (ReflectiveOperationException ex) {
    958                         warn("Cannot set Look and Feel: " + laf + ": "+ex.getMessage());
    959                     }
    960                 } else {
    961                     info("Look and Feel not found: " + laf);
     954            }
     955            if (klass != null && LookAndFeel.class.isAssignableFrom(klass)) {
     956                try {
     957                    UIManager.setLookAndFeel((LookAndFeel) klass.getConstructor().newInstance());
     958                } catch (ReflectiveOperationException ex) {
     959                    warn("Cannot set Look and Feel: " + laf + ": "+ex.getMessage());
     960                } catch (UnsupportedLookAndFeelException ex) {
     961                    info("Look and Feel not supported: " + laf);
    962962                    Main.pref.put("laf", defaultlaf);
    963963                }
    964             } catch (final UnsupportedLookAndFeelException e) {
    965                 info("Look and Feel not supported: " + laf);
     964            } else {
     965                info("Look and Feel not found: " + laf);
    966966                Main.pref.put("laf", defaultlaf);
    967967            }
    968             toolbar = new ToolbarPreferences();
    969             contentPanePrivate.updateUI();
    970             panel.updateUI();
    971         } catch (final Exception e) {
     968        } catch (UnsupportedLookAndFeelException e) {
     969            info("Look and Feel not supported: " + laf);
     970            Main.pref.put("laf", defaultlaf);
     971        } catch (InstantiationException | IllegalAccessException e) {
    972972            error(e);
    973973        }
     974        toolbar = new ToolbarPreferences();
     975        contentPanePrivate.updateUI();
     976        panel.updateUI();
     977
    974978        UIManager.put("OptionPane.okIcon", ImageProvider.get("ok"));
    975979        UIManager.put("OptionPane.yesIcon", UIManager.get("OptionPane.okIcon"));
  • trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java

    r9918 r10212  
    5454
    5555        // change toolbar icon from if specified
    56         try {
    57             String icon = info.getIcon();
    58             if (icon != null) {
    59                 new ImageProvider(icon).setOptional(true).getInBackground(new ImageResourceCallback() {
    60                             @Override
    61                             public void finished(final ImageResource result) {
    62                                 if (result != null) {
    63                                     GuiHelper.runInEDT(new Runnable() {
    64                                         @Override
    65                                         public void run() {
    66                                             result.getImageIcon(AddImageryLayerAction.this);
    67                                         }
    68                                     });
    69                                 }
     56        String icon = info.getIcon();
     57        if (icon != null) {
     58            new ImageProvider(icon).setOptional(true).getInBackground(new ImageResourceCallback() {
     59                        @Override
     60                        public void finished(final ImageResource result) {
     61                            if (result != null) {
     62                                GuiHelper.runInEDT(new Runnable() {
     63                                    @Override
     64                                    public void run() {
     65                                        result.getImageIcon(AddImageryLayerAction.this);
     66                                    }
     67                                });
    7068                            }
    71                         });
    72             }
    73         } catch (Exception ex) {
    74             throw new RuntimeException(ex.getMessage(), ex);
     69                        }
     70                    });
    7571        }
    7672    }
  • trunk/src/org/openstreetmap/josm/actions/CloseChangesetAction.java

    r9519 r10212  
    137137                        getProgressMonitor().createSubTaskMonitor(1, false /* not internal */)
    138138                );
    139             } catch (Exception e) {
     139            } catch (OsmTransferException | IllegalArgumentException e) {
    140140                if (canceled)
    141141                    return;
  • trunk/src/org/openstreetmap/josm/actions/JosmAction.java

    r10074 r10212  
    66import java.awt.event.KeyEvent;
    77import java.util.Collection;
     8import java.util.concurrent.CancellationException;
     9import java.util.concurrent.ExecutionException;
    810import java.util.concurrent.Future;
    911
     
    239241                        try {
    240242                            future.get();
    241                         } catch (Exception e) {
     243                        } catch (InterruptedException | ExecutionException | CancellationException e) {
    242244                            Main.error(e);
    243245                            return;
  • trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java

    r9972 r10212  
    2525import java.util.regex.Matcher;
    2626import java.util.regex.Pattern;
     27import java.util.regex.PatternSyntaxException;
    2728
    2829import javax.swing.JOptionPane;
     
    328329                            }
    329330                        }
    330                     } catch (Exception e) {
     331                    } catch (IOException | PatternSyntaxException | IllegalStateException | IndexOutOfBoundsException e) {
    331332                        Main.error(e);
    332333                    }
  • trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java

    r9972 r10212  
    153153                        result.add(task);
    154154                    }
    155                 } catch (Exception e) {
     155                } catch (ReflectiveOperationException e) {
    156156                    Main.error(e);
    157157                }
     
    173173                    DownloadTask task = taskClass.getConstructor().newInstance();
    174174                    result.append(task.acceptsDocumentationSummary());
    175                 } catch (Exception e) {
     175                } catch (ReflectiveOperationException e) {
    176176                    Main.error(e);
    177177                }
  • trunk/src/org/openstreetmap/josm/actions/RestartAction.java

    r9238 r10212  
    7979
    8080    /**
    81      * Restarts the current Java application
    82      * @throws IOException in case of any error
     81     * Restarts the current Java application.
     82     * @throws IOException in case of any I/O error
    8383     */
    8484    public static void restartJOSM() throws IOException {
    8585        if (isRestartSupported() && !Main.exitJosm(false, 0)) return;
    8686        final List<String> cmd;
    87         try {
    88             // special handling for OSX .app package
    89             if (Main.isPlatformOsx() && System.getProperty("java.library.path").contains("/JOSM.app/Contents/MacOS")) {
    90                 cmd = getAppleCommands();
    91             } else {
    92                 cmd = getCommands();
    93             }
    94             Main.info("Restart "+cmd);
    95             if (Main.isDebugEnabled() && Main.pref.getBoolean("restart.debug.simulation")) {
    96                 Main.debug("Restart cancelled to get debug info");
    97                 return;
    98             }
    99             // execute the command in a shutdown hook, to be sure that all the
    100             // resources have been disposed before restarting the application
    101             Runtime.getRuntime().addShutdownHook(new Thread("josm-restarter") {
    102                 @Override
    103                 public void run() {
    104                     try {
    105                         Runtime.getRuntime().exec(cmd.toArray(new String[cmd.size()]));
    106                     } catch (IOException e) {
    107                         Main.error(e);
    108                     }
     87        // special handling for OSX .app package
     88        if (Main.isPlatformOsx() && System.getProperty("java.library.path").contains("/JOSM.app/Contents/MacOS")) {
     89            cmd = getAppleCommands();
     90        } else {
     91            cmd = getCommands();
     92        }
     93        Main.info("Restart "+cmd);
     94        if (Main.isDebugEnabled() && Main.pref.getBoolean("restart.debug.simulation")) {
     95            Main.debug("Restart cancelled to get debug info");
     96            return;
     97        }
     98        // execute the command in a shutdown hook, to be sure that all the
     99        // resources have been disposed before restarting the application
     100        Runtime.getRuntime().addShutdownHook(new Thread("josm-restarter") {
     101            @Override
     102            public void run() {
     103                try {
     104                    Runtime.getRuntime().exec(cmd.toArray(new String[cmd.size()]));
     105                } catch (IOException e) {
     106                    Main.error(e);
    109107                }
    110             });
    111             // exit
    112             System.exit(0);
    113         } catch (Exception e) {
    114             // something went wrong
    115             throw new IOException("Error while trying to restart the application", e);
    116         }
     108            }
     109        });
     110        // exit
     111        System.exit(0);
    117112    }
    118113
  • trunk/src/org/openstreetmap/josm/actions/SessionLoadAction.java

    r10192 r10212  
    183183            } catch (IOException e) {
    184184                handleException(tr("IO Error"), e);
    185             } catch (Exception e) {
     185            } catch (RuntimeException e) {
    186186                cancel();
    187187                throw e;
  • trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java

    r9241 r10212  
    2323import org.openstreetmap.josm.io.MultiFetchServerObjectReader;
    2424import org.openstreetmap.josm.io.OnlineResource;
     25import org.openstreetmap.josm.io.OsmTransferException;
    2526import org.openstreetmap.josm.tools.Shortcut;
    2627
     
    4445            DataSet ds = reader.parseOsm(NullProgressMonitor.INSTANCE);
    4546            Main.main.getEditLayer().mergeFrom(ds);
    46         } catch (Exception e) {
     47        } catch (OsmTransferException e) {
    4748            ExceptionDialogUtil.explainException(e);
    4849        }
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java

    r9509 r10212  
    115115                ProgressMonitor subMonitor = progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false);
    116116                rawData = reader.parseRawGps(subMonitor);
    117             } catch (Exception e) {
     117            } catch (OsmTransferException e) {
    118118                if (isCanceled())
    119119                    return;
    120                 if (e instanceof OsmTransferException) {
    121                     rememberException(e);
    122                 } else {
    123                     rememberException(new OsmTransferException(e));
    124                 }
     120                rememberException(e);
    125121            }
    126122        }
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadNotesTask.java

    r10032 r10212  
    160160                                + "</html>",
    161161                        tr("More notes to download"), JOptionPane.INFORMATION_MESSAGE);
    162             } catch (Exception e) {
     162            } catch (OsmTransferException e) {
    163163                if (isCanceled())
    164164                    return;
    165                 if (e instanceof OsmTransferException) {
    166                     rememberException(e);
    167                 } else {
    168                     rememberException(new OsmTransferException(e));
    169                 }
     165                rememberException(e);
    170166            }
    171167        }
     
    186182            try {
    187183                notesData = reader.parseRawNotes(subMonitor);
    188             } catch (Exception e) {
     184            } catch (OsmTransferException e) {
    189185                if (isCanceled())
    190186                    return;
    191                 if (e instanceof OsmTransferException) {
    192                     rememberException(e);
    193                 } else {
    194                     rememberException(new OsmTransferException(e));
    195                 }
     187                rememberException(e);
    196188            }
    197189        }
     
    212204            try {
    213205                notesData = reader.parseRawNotesBzip2(subMonitor);
    214             } catch (Exception e) {
     206            } catch (OsmTransferException e) {
    215207                if (isCanceled())
    216208                    return;
    217                 if (e instanceof OsmTransferException) {
    218                     rememberException(e);
    219                 } else {
    220                     rememberException(new OsmTransferException(e));
    221                 }
     209                rememberException(e);
    222210            }
    223211        }
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

    r9732 r10212  
    332332                    return;
    333333                dataSet = parseDataSet();
    334             } catch (Exception e) {
     334            } catch (OsmTransferException e) {
    335335                if (isCanceled()) {
    336336                    Main.info(tr("Ignoring exception because download has been canceled. Exception was: {0}", e.toString()));
     
    340340                    setCanceled(true);
    341341                    return;
    342                 } else if (e instanceof OsmTransferException) {
     342                } else {
    343343                    rememberException(e);
    344                 } else {
    345                     rememberException(new OsmTransferException(e));
    346344                }
    347345                DownloadOsmTask.this.setFailed(true);
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadReferrersTask.java

    r9881 r10212  
    194194                i++;
    195195            }
    196         } catch (Exception e) {
     196        } catch (OsmTransferException e) {
    197197            if (canceled)
    198198                return;
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadTaskList.java

    r10135 r10212  
    1616import java.util.List;
    1717import java.util.Set;
     18import java.util.concurrent.CancellationException;
     19import java.util.concurrent.ExecutionException;
    1820import java.util.concurrent.Future;
    1921
     
    249251                try {
    250252                    future.get();
    251                 } catch (Exception e) {
     253                } catch (InterruptedException | ExecutionException | CancellationException e) {
    252254                    Main.error(e);
    253255                    return;
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/PostDownloadHandler.java

    r9905 r10212  
    99import java.util.LinkedHashSet;
    1010import java.util.Set;
     11import java.util.concurrent.CancellationException;
     12import java.util.concurrent.ExecutionException;
    1113import java.util.concurrent.Future;
    1214
     
    4042        try {
    4143            future.get();
    42         } catch (Exception e) {
     44        } catch (InterruptedException | ExecutionException | CancellationException e) {
    4345            Main.error(e);
    4446            return;
  • trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java

    r9981 r10212  
    598598                } catch (PatternSyntaxException e) {
    599599                    throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()), e);
    600                 } catch (Exception e) {
     600                } catch (IllegalArgumentException e) {
    601601                    throw new ParseError(tr(rxErrorMsgNoPos, key, e.getMessage()), e);
    602602                }
     
    605605                } catch (PatternSyntaxException e) {
    606606                    throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()), e);
    607                 } catch (Exception e) {
     607                } catch (IllegalArgumentException e) {
    608608                    throw new ParseError(tr(rxErrorMsgNoPos, value, e.getMessage()), e);
    609609                }
     
    795795                } catch (PatternSyntaxException e) {
    796796                    throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()), e);
    797                 } catch (Exception e) {
     797                } catch (IllegalArgumentException e) {
    798798                    throw new ParseError(tr(rxErrorMsgNoPos, key, e.getMessage()), e);
    799799                }
     
    806806                } catch (PatternSyntaxException e) {
    807807                    throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()), e);
    808                 } catch (Exception e) {
     808                } catch (IllegalArgumentException e) {
    809809                    throw new ParseError(tr(rxErrorMsgNoPos, value, e.getMessage()), e);
    810810                }
     
    885885                } catch (PatternSyntaxException e) {
    886886                    throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()), e);
    887                 } catch (Exception e) {
     887                } catch (IllegalArgumentException e) {
    888888                    throw new ParseError(tr(rxErrorMsgNoPos, s, e.getMessage()), e);
    889889                }
  • trunk/src/org/openstreetmap/josm/actions/upload/UploadNotesTask.java

    r10134 r10212  
    117117                }
    118118                updatedNotes.put(note, newNote);
    119             } catch (Exception e) {
     119            } catch (OsmTransferException e) {
    120120                Main.error("Failed to upload note to server: " + note.getId());
    121121                Main.error(e);
  • trunk/src/org/openstreetmap/josm/data/AutosaveTask.java

    r10043 r10212  
    165165                    try (PrintStream ps = new PrintStream(pidFile, "UTF-8")) {
    166166                        ps.println(ManagementFactory.getRuntimeMXBean().getName());
    167                     } catch (Exception t) {
     167                    } catch (IOException | SecurityException t) {
    168168                        Main.error(t);
    169169                    }
     
    213213                    displayNotification();
    214214                }
    215             } catch (Exception t) {
     215            } catch (RuntimeException t) {
    216216                // Don't let exception stop time thread
    217217                Main.error("Autosave failed:");
     
    312312                            skipFile = jvmPerfDataFileExists(pid);
    313313                        }
    314                     } catch (Exception t) {
     314                    } catch (IOException | SecurityException t) {
    315315                        Main.error(t);
    316316                    }
  • trunk/src/org/openstreetmap/josm/data/CustomConfigurator.java

    r10179 r10212  
    1010import java.io.File;
    1111import java.io.FileInputStream;
     12import java.io.IOException;
    1213import java.io.InputStream;
    1314import java.nio.charset.StandardCharsets;
     
    3536import javax.xml.parsers.DocumentBuilder;
    3637import javax.xml.parsers.DocumentBuilderFactory;
     38import javax.xml.parsers.ParserConfigurationException;
     39import javax.xml.stream.XMLStreamException;
    3740import javax.xml.transform.OutputKeys;
    3841import javax.xml.transform.Transformer;
     42import javax.xml.transform.TransformerException;
    3943import javax.xml.transform.TransformerFactory;
     44import javax.xml.transform.TransformerFactoryConfigurationError;
    4045import javax.xml.transform.dom.DOMSource;
    4146import javax.xml.transform.stream.StreamResult;
     
    5358import org.openstreetmap.josm.tools.LanguageInfo;
    5459import org.openstreetmap.josm.tools.Utils;
     60import org.w3c.dom.DOMException;
    5561import org.w3c.dom.Document;
    5662import org.w3c.dom.Element;
    5763import org.w3c.dom.Node;
    5864import org.w3c.dom.NodeList;
     65import org.xml.sax.SAXException;
    5966
    6067/**
     
    270277            exportDocument = builder.newDocument();
    271278            root = document.getDocumentElement();
    272         } catch (Exception ex) {
     279        } catch (SAXException | IOException | ParserConfigurationException ex) {
    273280            Main.warn("Error getting preferences to save:" +ex.getMessage());
    274281        }
    275         if (root == null)
     282        if (root == null || exportDocument == null)
    276283            return;
    277284        try {
     
    299306            ts.setOutputProperty(OutputKeys.INDENT, "yes");
    300307            ts.transform(new DOMSource(exportDocument), new StreamResult(f.toURI().getPath()));
    301         } catch (Exception ex) {
     308        } catch (DOMException | TransformerFactoryConfigurationError | TransformerException ex) {
    302309            Main.warn("Error saving preferences part:");
    303310            Main.error(ex);
     
    451458                    openAndReadXML(is);
    452459                }
    453             } catch (Exception ex) {
     460            } catch (ScriptException | IOException | SecurityException ex) {
    454461                log("Error reading custom preferences: " + ex.getMessage());
    455462            }
     
    466473                    processXML(document);
    467474                }
    468             } catch (Exception ex) {
     475            } catch (SAXException | IOException | ParserConfigurationException ex) {
    469476                log("Error reading custom preferences: "+ex.getMessage());
    470477            }
     
    492499                engine.eval("API.pluginUninstall = function(names) { "+className+".pluginOperation('',names,'');}");
    493500                engine.eval("API.pluginDelete = function(names) { "+className+".pluginOperation('','',names);}");
    494             } catch (Exception ex) {
     501            } catch (ScriptException ex) {
    495502                log("Error: initializing script engine: "+ex.getMessage());
    496503                Main.error(ex);
     
    747754                CharArrayReader reader = new CharArrayReader(fragmentWithReplacedVars.toCharArray());
    748755                tmpPref.fromXML(reader);
    749             } catch (Exception ex) {
     756            } catch (TransformerException | XMLStreamException | IOException ex) {
    750757                log("Error: can not read XML fragment :" + ex.getMessage());
    751758            }
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r10208 r10212  
    731731    /* only for preferences */
    732732    public synchronized String getColorName(String o) {
    733         try {
    734             Matcher m = Pattern.compile("mappaint\\.(.+?)\\.(.+)").matcher(o);
    735             if (m.matches()) {
    736                 return tr("Paint style {0}: {1}", tr(I18n.escape(m.group(1))), tr(I18n.escape(m.group(2))));
    737             }
    738         } catch (Exception e) {
    739             Main.warn(e);
    740         }
    741         try {
    742             Matcher m = Pattern.compile("layer (.+)").matcher(o);
    743             if (m.matches()) {
    744                 return tr("Layer: {0}", tr(I18n.escape(m.group(1))));
    745             }
    746         } catch (Exception e) {
    747             Main.warn(e);
     733        Matcher m = Pattern.compile("mappaint\\.(.+?)\\.(.+)").matcher(o);
     734        if (m.matches()) {
     735            return tr("Paint style {0}: {1}", tr(I18n.escape(m.group(1))), tr(I18n.escape(m.group(2))));
     736        }
     737        m = Pattern.compile("layer (.+)").matcher(o);
     738        if (m.matches()) {
     739            return tr("Layer: {0}", tr(I18n.escape(m.group(1))));
    748740        }
    749741        return tr(I18n.escape(colornames.containsKey(o) ? colornames.get(o) : o));
     
    13361328                field.setAccessible(true);
    13371329                field.set(null, ResourceBundle.getBundle("sun.awt.resources.awt"));
    1338             } catch (Exception | InternalError e) {
    1339                 // Ignore all exceptions, including internal error raised by Java 9 Jigsaw EA:
    1340                 // java.lang.InternalError: legacy getBundle can't be used to find sun.awt.resources.awt in module java.desktop
    1341                 // InternalError catch to remove when https://bugs.openjdk.java.net/browse/JDK-8136804 is resolved
     1330            } catch (ReflectiveOperationException e) {
    13421331                if (Main.isTraceEnabled()) {
    13431332                    Main.trace(e.getMessage());
  • trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java

    r10185 r10212  
    297297     * @return true if object was successfully downloaded, false, if there was a loading failure
    298298     */
    299 
    300299    private boolean loadObject() {
    301300        if (attributes == null) {
     
    396395            }
    397396            return doCache;
    398         } catch (Exception e) {
     397        } catch (InterruptedException e) {
    399398            attributes.setErrorMessage(e.toString());
    400399            log.log(Level.WARNING, "JCS - Exception during download {0}",  getUrlNoException());
     
    403402        log.log(Level.WARNING, "JCS - Silent failure during download: {0}", getUrlNoException());
    404403        return false;
    405 
    406404    }
    407405
  • trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java

    r9738 r10212  
    1212import org.openstreetmap.josm.data.coor.LatLon;
    1313import org.openstreetmap.josm.data.projection.Projections;
     14import org.openstreetmap.josm.tools.UncheckedParseException;
    1415import org.openstreetmap.josm.tools.date.DateUtils;
    1516import org.openstreetmap.josm.tools.template_engine.TemplateEngineDataProvider;
     
    124125                this.time = time.getTime() / 1000.;
    125126                return time;
    126             } catch (Exception e) {
     127            } catch (UncheckedParseException e) {
    127128                Main.warn(e);
    128129                time = 0;
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java

    r9989 r10212  
    665665
    666666        if (serverProjections == null || serverProjections.isEmpty()) {
    667             try {
    668                 serverProjections = new ArrayList<>();
    669                 Matcher m = Pattern.compile(".*\\{PROJ\\(([^)}]+)\\)\\}.*").matcher(url.toUpperCase(Locale.ENGLISH));
    670                 if (m.matches()) {
    671                     for (String p : m.group(1).split(",")) {
    672                         serverProjections.add(p);
    673                     }
     667            serverProjections = new ArrayList<>();
     668            Matcher m = Pattern.compile(".*\\{PROJ\\(([^)}]+)\\)\\}.*").matcher(url.toUpperCase(Locale.ENGLISH));
     669            if (m.matches()) {
     670                for (String p : m.group(1).split(",")) {
     671                    serverProjections.add(p);
    674672                }
    675             } catch (Exception e) {
    676                 Main.warn(e);
    677673            }
    678674        }
  • trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java

    r10087 r10212  
    152152        try {
    153153            super.submit(this, force);
    154         } catch (Exception e) {
     154        } catch (IOException e) {
    155155            // if we fail to submit the job, mark tile as loaded and set error message
    156156            tile.finishLoading();
  • trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java

    r10043 r10212  
    252252     * @param info imagery info
    253253     * @throws IOException if any I/O error occurs
     254     * @throws IllegalArgumentException if any other error happens for the given imagery info
    254255     */
    255256    public WMTSTileSource(ImageryInfo info) throws IOException {
     
    290291    }
    291292
    292     private Collection<Layer> getCapabilities() {
     293    /**
     294     * @return capabilities
     295     * @throws IOException in case of any I/O error
     296     * @throws IllegalArgumentException in case of any other error
     297     */
     298    private Collection<Layer> getCapabilities() throws IOException {
    293299        XMLInputFactory factory = XMLInputFactory.newFactory();
    294300        // do not try to load external entities, nor validate the XML
     
    320326            }
    321327            return ret;
    322         } catch (Exception e) {
     328        } catch (XMLStreamException e) {
    323329            throw new IllegalArgumentException(e);
    324330        }
  • trunk/src/org/openstreetmap/josm/data/osm/DatasetConsistencyTest.java

    r8846 r10212  
    212212            }
    213213
    214         } catch (Exception e) {
     214        } catch (RuntimeException e) {
    215215            writer.println("Exception during dataset integrity test:");
    216216            e.printStackTrace(writer);
  • trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java

    r10181 r10212  
    814814                        }
    815815                    }
    816                 } catch (Exception e) {
     816                } catch (RuntimeException e) {
    817817                    Main.error(e);
    818818                }
  • trunk/src/org/openstreetmap/josm/data/projection/Projections.java

    r9950 r10212  
    323323            try {
    324324                proj = pc.getProjection();
    325             } catch (Exception e) {
     325            } catch (RuntimeException e) {
    326326                String cause = e.getMessage();
    327327                Main.warn("Unable to get projection "+code+" with "+pc + (cause != null ? ". "+cause : ""));
  • trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2GridShiftFileWrapper.java

    r9639 r10212  
    22package org.openstreetmap.josm.data.projection.datum;
    33
     4import java.io.IOException;
    45import java.io.InputStream;
    56
     
    5556                instance = new NTV2GridShiftFile();
    5657                instance.loadGridShiftFile(is, false);
    57             } catch (Exception e) {
     58            } catch (IOException e) {
    5859                throw new RuntimeException(e);
    5960            }
  • trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java

    r10208 r10212  
    162162
    163163    /**
    164      * Check if plugin directory exists (store ignored errors file)
     164     * Check if validator directory exists (store ignored errors file)
    165165     */
    166166    private static void checkValidatorDir() {
    167         try {
    168             File pathDir = new File(getValidatorDir());
    169             if (!pathDir.exists()) {
    170                 Utils.mkDirs(pathDir);
    171             }
    172         } catch (Exception e) {
    173             Main.error(e);
     167        File pathDir = new File(getValidatorDir());
     168        if (!pathDir.exists()) {
     169            Utils.mkDirs(pathDir);
    174170        }
    175171    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r9799 r10212  
    750750                Main.warn(tr("Failed to add {0} to tag checker", i));
    751751                Main.warn(ex, false);
    752             } catch (Exception ex) {
     752            } catch (ParseException ex) {
    753753                Main.warn(tr("Failed to add {0} to tag checker", i));
    754754                Main.warn(ex);
  • trunk/src/org/openstreetmap/josm/data/validation/tests/OpeningHourTest.java

    r10043 r10212  
    207207            try {
    208208                prettifiedValue = (String) ((Invocable) ENGINE).invokeMethod(r, "prettifyValue");
    209             } catch (Exception e) {
    210                 Main.debug(e.getMessage());
     209            } catch (ScriptException | NoSuchMethodException e) {
     210                Main.warn(e);
    211211            }
    212212            for (final Object i : getList(((Invocable) ENGINE).invokeMethod(r, "getErrors"))) {
  • trunk/src/org/openstreetmap/josm/gui/FileDrop.java

    r9992 r10212  
    2323import java.io.Reader;
    2424import java.net.URI;
     25import java.net.URISyntaxException;
    2526import java.util.ArrayList;
    2627import java.util.Arrays;
     
    3435import org.openstreetmap.josm.Main;
    3536import org.openstreetmap.josm.actions.OpenFileAction;
     37import org.openstreetmap.josm.gui.FileDrop.TransferableObject;
    3638
    3739// CHECKSTYLE.OFF: HideUtilityClassConstructor
     
    138140        try {
    139141            List<File> list = new ArrayList<>();
    140             String line = null;
     142            String line;
    141143            while ((line = bReader.readLine()) != null) {
    142144                try {
     
    146148                    }
    147149
    148                     File file = new File(new URI(line));
    149                     list.add(file);
    150                 } catch (Exception ex) {
     150                    list.add(new File(new URI(line)));
     151                } catch (URISyntaxException ex) {
    151152                    Main.warn("Error with " + line + ": " + ex.getMessage());
    152153                }
  • trunk/src/org/openstreetmap/josm/gui/JosmUserIdentityManager.java

    r9759 r10212  
    6666                try {
    6767                    instance.initFromOAuth();
    68                 } catch (Exception e) {
     68                } catch (RuntimeException e) {
    6969                    Main.error(e);
    7070                    // Fall back to preferences if OAuth identification fails for any reason
     
    304304            accessTokenSecretChanged = false;
    305305            if (OsmApi.isUsingOAuth()) {
    306                 try {
    307                     getInstance().initFromOAuth();
    308                 } catch (Exception e) {
    309                     Main.error(e);
    310                 }
     306                getInstance().initFromOAuth();
    311307            }
    312308        }
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r10200 r10212  
    403403                try (InputStream is = HttpClient.create(new URL(i)).connect().getContent()) {
    404404                    config.openAndReadXML(is);
    405                 } catch (Exception ex) {
     405                } catch (IOException ex) {
    406406                    throw new RuntimeException(ex);
    407407                }
  • trunk/src/org/openstreetmap/josm/gui/MapStatus.java

    r10191 r10212  
    10971097            try {
    10981098                thread.interrupt();
    1099             } catch (Exception e) {
     1099            } catch (RuntimeException e) {
    11001100                Main.error(e);
    11011101            }
  • trunk/src/org/openstreetmap/josm/gui/PleaseWaitRunnable.java

    r10055 r10212  
    55import java.awt.EventQueue;
    66import java.io.IOException;
     7import java.lang.reflect.InvocationTargetException;
    78
    89import javax.swing.SwingUtilities;
     
    122123                }
    123124            }
    124         } catch (final Exception e) {
     125        } catch (final RuntimeException |
     126                OsmTransferException | IOException | SAXException | InvocationTargetException | InterruptedException e) {
    125127            if (!ignoreException) {
    126128                // Exception has to thrown in EDT to be shown to user
  • trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java

    r10001 r10212  
    199199    @Override
    200200    public void paint(Graphics g) {
    201         try {
    202             super.paint(g);
    203 
    204             // draw selection rectangle
    205             if (iSelectionRectStart != null && iSelectionRectEnd != null) {
    206                 Rectangle box = new Rectangle(getMapPosition(iSelectionRectStart, false));
    207                 box.add(getMapPosition(iSelectionRectEnd, false));
    208 
    209                 g.setColor(new Color(0.9f, 0.7f, 0.7f, 0.6f));
    210                 g.fillRect(box.x, box.y, box.width, box.height);
    211 
    212                 g.setColor(Color.BLACK);
    213                 g.drawRect(box.x, box.y, box.width, box.height);
    214             }
    215         } catch (Exception e) {
    216             Main.error(e);
     201        super.paint(g);
     202
     203        // draw selection rectangle
     204        if (iSelectionRectStart != null && iSelectionRectEnd != null) {
     205            Rectangle box = new Rectangle(getMapPosition(iSelectionRectStart, false));
     206            box.add(getMapPosition(iSelectionRectEnd, false));
     207
     208            g.setColor(new Color(0.9f, 0.7f, 0.7f, 0.6f));
     209            g.fillRect(box.x, box.y, box.width, box.height);
     210
     211            g.setColor(Color.BLACK);
     212            g.drawRect(box.x, box.y, box.width, box.height);
    217213        }
    218214    }
  • trunk/src/org/openstreetmap/josm/gui/bbox/TileSelectionBBoxChooser.java

    r10179 r10212  
    4545import org.openstreetmap.gui.jmapviewer.interfaces.MapMarker;
    4646import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader;
    47 import org.openstreetmap.josm.Main;
    4847import org.openstreetmap.josm.data.Bounds;
    4948import org.openstreetmap.josm.data.Version;
     
    694693        @Override
    695694        public void paint(Graphics g) {
    696             try {
    697                 super.paint(g);
    698                 if (min == null || max == null) return;
    699                 int zoomDiff = MAX_ZOOM - zoom;
    700                 Point tlc = getTopLeftCoordinates();
    701                 int xMin = (min.x >> zoomDiff) - tlc.x;
    702                 int yMin = (min.y >> zoomDiff) - tlc.y;
    703                 int xMax = (max.x >> zoomDiff) - tlc.x;
    704                 int yMax = (max.y >> zoomDiff) - tlc.y;
    705 
    706                 int w = xMax - xMin;
    707                 int h = yMax - yMin;
    708                 g.setColor(new Color(0.9f, 0.7f, 0.7f, 0.6f));
    709                 g.fillRect(xMin, yMin, w, h);
    710 
    711                 g.setColor(Color.BLACK);
    712                 g.drawRect(xMin, yMin, w, h);
    713             } catch (Exception e) {
    714                 Main.error(e);
    715             }
     695            super.paint(g);
     696            if (min == null || max == null) return;
     697            int zoomDiff = MAX_ZOOM - zoom;
     698            Point tlc = getTopLeftCoordinates();
     699            int xMin = (min.x >> zoomDiff) - tlc.x;
     700            int yMin = (min.y >> zoomDiff) - tlc.y;
     701            int xMax = (max.x >> zoomDiff) - tlc.x;
     702            int yMax = (max.y >> zoomDiff) - tlc.y;
     703
     704            int w = xMax - xMin;
     705            int h = yMax - yMin;
     706            g.setColor(new Color(0.9f, 0.7f, 0.7f, 0.6f));
     707            g.fillRect(xMin, yMin, w, h);
     708
     709            g.setColor(Color.BLACK);
     710            g.drawRect(xMin, yMin, w, h);
    716711        }
    717712    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentPanel.java

    r10124 r10212  
    235235                        });
    236236                    }
    237                 } catch (final Exception e) {
     237                } catch (final RuntimeException e) {
    238238                    GuiHelper.runInEDT(new Runnable() {
    239239                        @Override
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r10106 r10212  
    1616import java.beans.PropertyChangeEvent;
    1717import java.beans.PropertyChangeListener;
     18import java.io.IOException;
    1819import java.net.URI;
    1920import java.net.URISyntaxException;
     
    12161217                                }
    12171218                            }
    1218                         } catch (Exception e) {
     1219                        } catch (URISyntaxException | IOException e) {
    12191220                            Main.error(e);
    12201221                        }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ChildRelationBrowser.java

    r9543 r10212  
    426426                    }
    427427                });
    428             } catch (Exception e) {
     428            } catch (OsmTransferException e) {
    429429                if (canceled) {
    430430                    Main.warn(tr("Ignoring exception because task was canceled. Exception: {0}", e.toString()));
     
    475475                    refreshView(r);
    476476                }
    477             } catch (Exception e) {
     477            } catch (OsmTransferException e) {
    478478                if (canceled) {
    479479                    Main.warn(tr("Ignoring exception because task was canceled. Exception: {0}", e.toString()));
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/DownloadRelationMemberTask.java

    r9241 r10212  
    143143            );
    144144
    145         } catch (Exception e) {
     145        } catch (OsmTransferException e) {
    146146            if (canceled) {
    147147                Main.warn(tr("Ignoring exception because task was canceled. Exception: {0}", e.toString()));
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/DownloadRelationTask.java

    r9078 r10212  
    55
    66import java.io.IOException;
     7import java.lang.reflect.InvocationTargetException;
    78import java.util.Collection;
    89
     
    107108                    }
    108109            );
    109         } catch (Exception e) {
     110        } catch (OsmTransferException | InvocationTargetException | InterruptedException e) {
    110111            if (canceled) {
    111112                Main.warn(tr("Ignoring exception because task was canceled. Exception: {0}", e.toString()));
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTransferHandler.java

    r9993 r10212  
    5454                importPrimitiveData(support, destination, insertRow);
    5555            }
    56         } catch (Exception e) {
     56        } catch (IOException | UnsupportedFlavorException e) {
    5757            Main.warn(e);
    5858            return false;
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ParentRelationLoadingTask.java

    r9999 r10212  
    188188                );
    189189            }
    190         } catch (Exception e) {
     190        } catch (OsmTransferException e) {
    191191            if (canceled) {
    192192                Main.warn(tr("Ignoring exception because task was canceled. Exception: {0}", e.toString()));
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationEditor.java

    r10113 r10212  
    106106                    return e.getConstructor(Relation.class, Collection.class).newInstance(layer, r, selectedMembers);
    107107                }
    108             } catch (Exception ex) {
     108            } catch (ReflectiveOperationException ex) {
    109109                Main.warn(ex);
    110110            }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationTree.java

    r9078 r10212  
    157157                ds = reader.parseOsm(progressMonitor
    158158                        .createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));
    159             } catch (Exception e) {
     159            } catch (OsmTransferException e) {
    160160                if (canceled) {
    161161                    Main.warn(tr("Ignoring exception because task was canceled. Exception: {0}", e.toString()));
  • trunk/src/org/openstreetmap/josm/gui/download/BookmarkList.java

    r9371 r10212  
    147147                try {
    148148                    bookmarks.add(new Bookmark(entry));
    149                 } catch (Exception e) {
     149                } catch (IllegalArgumentException e) {
    150150                    Main.error(tr("Error reading bookmark entry: %s", e.getMessage()));
    151151                }
  • trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java

    r10179 r10212  
    144144        try {
    145145            tpDownloadAreaSelectors.setSelectedIndex(Main.pref.getInteger("download.tab", 0));
    146         } catch (Exception ex) {
     146        } catch (IndexOutOfBoundsException ex) {
    147147            Main.pref.putInteger("download.tab", 0);
    148148        }
  • trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java

    r9972 r10212  
    4141import javax.swing.table.TableCellRenderer;
    4242import javax.swing.table.TableColumn;
     43import javax.xml.parsers.ParserConfigurationException;
    4344
    4445import org.openstreetmap.josm.Main;
     
    396397                    });
    397398                }
    398             } catch (Exception e) {
     399            } catch (IOException | ParserConfigurationException e) {
    399400                if (!canceled) {
    400401                    OsmTransferException ex = new OsmTransferException(e);
  • trunk/src/org/openstreetmap/josm/gui/help/HelpBrowser.java

    r10210 r10212  
    1616import java.awt.event.WindowEvent;
    1717import java.io.BufferedReader;
     18import java.io.IOException;
    1819import java.io.InputStreamReader;
    1920import java.io.StringReader;
     
    155156                css.append('\n');
    156157            }
    157         } catch (Exception e) {
     158        } catch (IOException e) {
    158159            Main.error(tr("Failed to read CSS file ''help-browser.css''. Exception is: {0}", e.toString()));
    159160            Main.error(e);
     
    239240        try {
    240241            help.getEditorKit().read(new StringReader(content), document, 0);
    241         } catch (Exception e) {
     242        } catch (IOException | BadLocationException e) {
    242243            Main.error(e);
    243244        }
     
    376377                history.setCurrentUrl(url);
    377378                this.url = url;
    378             } catch (Exception e) {
     379            } catch (HelpContentReaderException e) {
    379380                Main.warn(e);
    380381                HelpAwareOptionPane.showOptionDialog(
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java

    r10173 r10212  
    211211                        });
    212212                    }
    213                 } catch (final Exception e) {
     213                } catch (final RuntimeException e) {
    214214                    BugReportExceptionHandler.handleException(e);
    215215                }
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java

    r10210 r10212  
    143143        try {
    144144            HistoryOsmPrimitive.forOsmPrimitive(primitive);
    145         } catch (Exception ign) {
     145        } catch (IllegalArgumentException ign) {
    146146            return false;
    147147        }
  • trunk/src/org/openstreetmap/josm/gui/io/AbstractPrimitiveTask.java

    r10129 r10212  
    113113
    114114            loadIncompleteNodes();
    115         } catch (Exception e) {
     115        } catch (OsmTransferException e) {
    116116            if (canceled)
    117117                return;
  • trunk/src/org/openstreetmap/josm/gui/io/CloseChangesetTask.java

    r9078 r10212  
    8080                closedChangesets.add(cs);
    8181            }
    82         } catch (Exception e) {
     82        } catch (OsmTransferException e) {
    8383            if (canceled)
    8484                return;
  • trunk/src/org/openstreetmap/josm/gui/io/DownloadOpenChangesetsTask.java

    r10035 r10212  
    154154                    getProgressMonitor().createSubTaskMonitor(1, false /* not internal */)
    155155            );
    156         } catch (Exception e) {
     156        } catch (OsmTransferException e) {
    157157            if (canceled)
    158158                return;
  • trunk/src/org/openstreetmap/josm/gui/io/SaveLayerTask.java

    r9078 r10212  
    5656                layerInfo.getLayer().onPostSaveToFile();
    5757            }
    58         } catch (Exception e) {
     58        } catch (RuntimeException e) {
    5959            Main.error(e);
    6060            setLastException(e);
  • trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java

    r10190 r10212  
    2121import java.util.List;
    2222import java.util.concurrent.CancellationException;
     23import java.util.concurrent.ExecutionException;
    2324import java.util.concurrent.ExecutorService;
    2425import java.util.concurrent.Executors;
     
    496497                } catch (CancellationException e) {
    497498                    model.setUploadState(layer, UploadOrSaveState.CANCELED);
    498                 } catch (Exception e) {
     499                } catch (InterruptedException | ExecutionException e) {
    499500                    Main.error(e);
    500501                    model.setUploadState(layer, UploadOrSaveState.FAILED);
     
    537538                } catch (CancellationException e) {
    538539                    model.setSaveState(layerInfo.getLayer(), UploadOrSaveState.CANCELED);
    539                 } catch (Exception e) {
     540                } catch (InterruptedException | ExecutionException e) {
    540541                    Main.error(e);
    541542                    model.setSaveState(layerInfo.getLayer(), UploadOrSaveState.FAILED);
  • trunk/src/org/openstreetmap/josm/gui/io/UploadLayerTask.java

    r9543 r10212  
    137137                }
    138138            }
    139         } catch (Exception sxe) {
     139        } catch (OsmTransferException sxe) {
    140140            if (isCanceled()) {
    141141                Main.info("Ignoring exception caught because upload is canceled. Exception is: " + sxe);
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java

    r10209 r10212  
    465465                public void valueChanged(ListSelectionEvent arg0) {
    466466                    int index = imgList.getSelectedIndex();
    467                     Integer orientation = null;
    468                     try {
    469                         orientation = ExifReader.readOrientation(yLayer.data.get(index).getFile());
    470                     } catch (Exception e) {
    471                         Main.warn(e);
    472                     }
     467                    Integer orientation = ExifReader.readOrientation(yLayer.data.get(index).getFile());
    473468                    imgDisp.setImage(yLayer.data.get(index).getFile(), orientation);
    474469                    Date date = yLayer.data.get(index).getExifTime();
     
    500495                    File sel = fc.getSelectedFile();
    501496
    502                     Integer orientation = null;
    503                     try {
    504                         orientation = ExifReader.readOrientation(sel);
    505                     } catch (Exception e) {
    506                         Main.warn(e);
    507                     }
     497                    Integer orientation = ExifReader.readOrientation(sel);
    508498                    imgDisp.setImage(sel, orientation);
    509499
    510                     Date date = null;
    511                     try {
    512                         date = ExifReader.readTime(sel);
    513                     } catch (Exception e) {
    514                         Main.warn(e);
    515                     }
     500                    Date date = ExifReader.readTime(sel);
    516501                    if (date != null) {
    517502                        lbExifTime.setText(DateUtils.getDateTimeFormat(DateFormat.SHORT, DateFormat.MEDIUM).format(date));
     
    967952                final long deciSeconds = timezoneOffsetPair.b.getMilliseconds() / 100;
    968953                sldSeconds.setValue((int) (deciSeconds % 60));
    969             } catch (Exception e) {
     954            } catch (RuntimeException e) {
    970955                JOptionPane.showMessageDialog(Main.parent,
    971956                        tr("An error occurred while trying to match the photos to the GPX track."
     
    10151000            for (GpxTrackSegment segment : trk.getSegments()) {
    10161001                for (WayPoint curWp : segment.getWayPoints()) {
    1017                     try {
    1018                         final Date parsedTime = curWp.setTimeFromAttribute();
    1019                         if (parsedTime != null) {
    1020                             firstGPXDate = parsedTime.getTime();
    1021                             break outer;
    1022                         }
    1023                     } catch (Exception e) {
    1024                         Main.warn(e);
     1002                    final Date parsedTime = curWp.setTimeFromAttribute();
     1003                    if (parsedTime != null) {
     1004                        firstGPXDate = parsedTime.getTime();
     1005                        break outer;
    10251006                    }
    10261007                }
     
    11501131
    11511132                for (WayPoint curWp : segment.getWayPoints()) {
    1152                     try {
    1153                         final Date parsedTime = curWp.setTimeFromAttribute();
    1154                         if (parsedTime != null) {
    1155                             final long curWpTime = parsedTime.getTime() + offset;
    1156                             ret += matchPoints(images, prevWp, prevWpTime, curWp, curWpTime, offset);
    1157 
    1158                             prevWp = curWp;
    1159                             prevWpTime = curWpTime;
    1160                             continue;
    1161                         }
    1162                     } catch (Exception e) {
    1163                         Main.warn(e);
     1133                    final Date parsedTime = curWp.setTimeFromAttribute();
     1134                    if (parsedTime != null) {
     1135                        final long curWpTime = parsedTime.getTime() + offset;
     1136                        ret += matchPoints(images, prevWp, prevWpTime, curWp, curWpTime, offset);
     1137
     1138                        prevWp = curWp;
     1139                        prevWpTime = curWpTime;
     1140                        continue;
    11641141                    }
    11651142                    prevWp = null;
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java

    r9383 r10212  
    492492            // default is K (km/h)
    493493            setSpeed(speed);
    494         } catch (Exception ex) {
     494        } catch (MetadataException ex) {
    495495            if (Main.isDebugEnabled()) {
    496496                Main.debug(ex.getMessage());
     
    516516            setPos(getExifCoor());
    517517
    518         } catch (Exception ex) { // (other exceptions, e.g. #5271)
     518        } catch (MetadataException | IndexOutOfBoundsException ex) { // (other exceptions, e.g. #5271)
    519519            Main.error("Error reading EXIF from file: " + ex);
    520520            setExifCoor(null);
     
    527527                setExifImgDir(direction);
    528528            }
    529         } catch (Exception ex) { // (CompoundException and other exceptions, e.g. #5271)
     529        } catch (IndexOutOfBoundsException ex) { // (other exceptions, e.g. #5271)
    530530            if (Main.isDebugEnabled()) {
    531531                Main.debug(ex.getMessage());
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java

    r10186 r10212  
    164164            int i = Main.pref.getInteger("draw.rawgps.colors", specName(layerName), 0);
    165165            return ColorMode.fromIndex(i);
    166         } catch (Exception e) {
     166        } catch (IndexOutOfBoundsException e) {
    167167            Main.warn(e);
    168168        }
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java

    r9779 r10212  
    5151    public static PlayHeadMarker create() {
    5252        if (playHead == null) {
    53             try {
    54                 playHead = new PlayHeadMarker();
    55             } catch (Exception ex) {
    56                 Main.error(ex);
    57                 return null;
    58             }
     53            playHead = new PlayHeadMarker();
    5954        }
    6055        return playHead;
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/WebMarker.java

    r8846 r10212  
    6666            try {
    6767                setErroneous(path.isEmpty() || !new File(path).exists());
    68             } catch (Exception e) {
     68            } catch (SecurityException e) {
    6969                Main.warn(e);
    7070                setErroneous(true);
  • trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java

    r10055 r10212  
    622622                                } catch (SecurityException ex) {
    623623                                    Main.error(ex);
    624                                 } catch (Exception ex) {
     624                                } catch (RuntimeException ex) {
    625625                                    BugReportExceptionHandler.handleException(ex);
    626626                                } finally {
     
    636636                } catch (SecurityException ex) {
    637637                    Main.error(ex);
    638                 } catch (Exception ex) {
     638                } catch (RuntimeException ex) {
    639639                    // allow to change most settings even if e.g. a plugin fails
    640640                    BugReportExceptionHandler.handleException(ex);
  • trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java

    r10179 r10212  
    504504            loader.realRun();
    505505            return loader.sources;
    506         } catch (Exception ex) {
     506        } catch (IOException | SAXException | OsmTransferException ex) {
    507507            throw new RuntimeException(ex);
    508508        }
  • trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java

    r10179 r10212  
    575575                    movingComponent = "";
    576576                    return true;
    577                 } catch (Exception e) {
     577                } catch (IOException | UnsupportedFlavorException e) {
    578578                    Main.error(e);
    579579                }
     
    594594                            }
    595595                        }
    596                     } catch (Exception e) {
     596                    } catch (IOException | UnsupportedFlavorException e) {
    597597                        Main.error(e);
    598598                    }
  • trunk/src/org/openstreetmap/josm/gui/preferences/display/LafPreference.java

    r10001 r10212  
    8484                        new UIManager.LookAndFeelInfo(((LookAndFeel) oquaqua).getName(), "ch.randelshofer.quaqua.QuaquaLookAndFeel")
    8585                );
    86             } catch (Exception ex) {
     86            } catch (ReflectiveOperationException ex) {
    8787                // just debug, Quaqua may not even be installed...
    8888                Main.debug(ex.getMessage());
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/OsmApiUrlInputPanel.java

    r10179 r10212  
    3636import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator;
    3737import org.openstreetmap.josm.io.OsmApi;
     38import org.openstreetmap.josm.io.OsmApiInitializationException;
     39import org.openstreetmap.josm.io.OsmTransferCanceledException;
    3840import org.openstreetmap.josm.tools.ImageProvider;
    3941import org.openstreetmap.josm.tools.Utils;
     
    157159            try {
    158160                OsmApi.getOsmApi().initialize(null);
    159             } catch (Exception x) {
     161            } catch (OsmTransferCanceledException | OsmApiInitializationException x) {
    160162                Main.warn(x);
    161163            }
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItem.java

    r10001 r10212  
    118118        try {
    119119            return Integer.valueOf(str);
    120         } catch (Exception e) {
     120        } catch (NumberFormatException e) {
    121121            if (Main.isTraceEnabled()) {
    122122                Main.trace(e.getMessage());
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java

    r9996 r10212  
    447447                                "public static String[] methodName()"));
    448448                    }
    449                 } catch (Exception e) {
     449                } catch (ReflectiveOperationException e) {
    450450                    Main.error(tr("Broken tagging preset \"{0}-{1}\" - Java method given in ''values_from'' threw {2} ({3})", key, text,
    451451                            e.getClass().getName(), e.getMessage()));
  • trunk/src/org/openstreetmap/josm/gui/widgets/AbstractIdTextField.java

    r8308 r10212  
    3838                validator = klass.getConstructor(JTextComponent.class).newInstance(this);
    3939            }
    40         } catch (Exception e) {
     40        } catch (ReflectiveOperationException e) {
    4141            Main.error(e);
    4242        } finally {
  • trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java

    r10194 r10212  
    192192        } catch (OsmTransferException e) {
    193193            throw e;
    194         } catch (Exception e) {
     194        } catch (IllegalDataException | IOException e) {
    195195            throw new OsmTransferException(e);
    196196        } finally {
  • trunk/src/org/openstreetmap/josm/io/CachedFile.java

    r10194 r10212  
    352352                Utils.close(zipFile);
    353353            }
    354         } catch (Exception e) {
     354        } catch (IOException e) {
    355355            if (file.getName().endsWith(".zip")) {
    356356                Main.warn(tr("Failed to open file with extension ''{2}'' and namepart ''{3}'' in zip file ''{0}''. Exception was: {1}",
  • trunk/src/org/openstreetmap/josm/io/FileImporter.java

    r9231 r10212  
    9999            }
    100100            return false;
    101         } catch (Exception e) {
     101        } catch (IOException e) {
    102102            displayError(f, e);
    103103            return false;
     
    138138            importData(files, progressMonitor);
    139139            return true;
    140         } catch (Exception e) {
     140        } catch (IOException | IllegalDataException e) {
    141141            Main.error(e);
    142142            HelpAwareOptionPane.showMessageDialogInEDT(
  • trunk/src/org/openstreetmap/josm/io/GpxReader.java

    r10045 r10212  
    409409                    try {
    410410                        currentWayPoint.put(localName, Float.valueOf(accumulator.toString()));
    411                     } catch (Exception e) {
     411                    } catch (NumberFormatException e) {
    412412                        currentWayPoint.put(localName, 0f);
    413413                    }
  • trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java

    r9325 r10212  
    522522                try {
    523523                    result = new FetchResult(OsmReader.parseDataSet(in, progressMonitor.createSubTaskMonitor(pkg.size(), false)), null);
    524                 } catch (Exception e) {
     524                } catch (IllegalDataException e) {
    525525                    throw new OsmTransferException(e);
    526526                }
     
    550550                try {
    551551                    result = OsmReader.parseDataSet(in, progressMonitor.createSubTaskMonitor(1, false));
    552                 } catch (Exception e) {
     552                } catch (IllegalDataException e) {
    553553                    throw new OsmTransferException(e);
    554554                }
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r10051 r10212  
    263263            Main.addNetworkError(url, Utils.getRootCause(e));
    264264            throw new OsmApiInitializationException(e);
    265         } catch (Exception e) {
     265        } catch (SAXException | IOException | ParserConfigurationException e) {
    266266            initialized = false;
    267267            throw new OsmApiInitializationException(e);
  • trunk/src/org/openstreetmap/josm/io/OsmApiException.java

    r8513 r10212  
    144144                .append('>');
    145145            }
    146         } catch (Exception e) {
     146        } catch (IllegalArgumentException e) {
    147147            // Ignored
    148148            if (Main.isTraceEnabled()) {
     
    157157                .append('>');
    158158            }
    159         } catch (Exception e) {
     159        } catch (IllegalArgumentException e) {
    160160            // Ignored
    161161            if (Main.isTraceEnabled()) {
  • trunk/src/org/openstreetmap/josm/io/OsmChangesetParser.java

    r10001 r10212  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.io.IOException;
    67import java.io.InputStream;
    78import java.io.InputStreamReader;
     
    283284        } catch (ParserConfigurationException | SAXException e) {
    284285            throw new IllegalDataException(e.getMessage(), e);
    285         } catch (Exception e) {
     286        } catch (IOException e) {
    286287            throw new IllegalDataException(e);
    287288        } finally {
  • trunk/src/org/openstreetmap/josm/io/OsmReader.java

    r9326 r10212  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.io.IOException;
    67import java.io.InputStream;
    78import java.io.InputStreamReader;
     
    651652            else
    652653                throw new IllegalDataException(msg, e);
    653         } catch (Exception e) {
     654        } catch (IOException e) {
    654655            throw new IllegalDataException(e);
    655656        } finally {
  • trunk/src/org/openstreetmap/josm/io/OsmServerBackreferenceReader.java

    r9231 r10212  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.io.IOException;
    67import java.io.InputStream;
    78import java.text.MessageFormat;
     
    135136        } catch (OsmTransferException e) {
    136137            throw e;
    137         } catch (Exception e) {
     138        } catch (IOException | IllegalDataException e) {
    138139            if (cancel)
    139140                return null;
  • trunk/src/org/openstreetmap/josm/io/OsmServerHistoryReader.java

    r9231 r10212  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.io.IOException;
    67import java.io.InputStream;
    78import java.text.MessageFormat;
     
    1213import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    1314import org.openstreetmap.josm.tools.CheckParameterUtil;
     15import org.xml.sax.SAXException;
    1416
    1517/**
     
    7274        } catch (OsmTransferException e) {
    7375            throw e;
    74         } catch (Exception e) {
     76        } catch (IOException | SAXException e) {
    7577            if (cancel)
    7678                return null;
  • trunk/src/org/openstreetmap/josm/io/OsmServerLocationReader.java

    r9990 r10212  
    5252        } catch (OsmTransferException e) {
    5353            throw e;
    54         } catch (Exception e) {
     54        } catch (IOException | SAXException | IllegalDataException e) {
    5555            if (cancel)
    5656                return null;
  • trunk/src/org/openstreetmap/josm/io/OsmServerObjectReader.java

    r8510 r10212  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.io.IOException;
    67import java.io.InputStream;
    78import java.text.MessageFormat;
     
    134135            if (cancel) return null;
    135136            throw e;
    136         } catch (Exception e) {
     137        } catch (IOException | IllegalDataException e) {
    137138            if (cancel) return null;
    138139            throw new OsmTransferException(e);
  • trunk/src/org/openstreetmap/josm/io/OsmServerReader.java

    r9732 r10212  
    144144            try {
    145145                response = client.connect(progressMonitor);
    146             } catch (Exception e) {
     146            } catch (IOException e) {
    147147                Main.error(e);
    148148                OsmTransferException ote = new OsmTransferException(
     
    163163                    try {
    164164                        errorBody = response.fetchContent();
    165                     } catch (Exception e) {
     165                    } catch (IOException e) {
    166166                        errorBody = tr("Reading error text failed.");
    167167                    }
     
    173173            } catch (OsmTransferException e) {
    174174                throw e;
    175             } catch (Exception e) {
     175            } catch (IOException e) {
    176176                throw new OsmTransferException(e);
    177177            }
  • trunk/src/org/openstreetmap/josm/io/OsmServerUserInfoReader.java

    r8540 r10212  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.io.IOException;
    67import java.io.InputStream;
    78import java.util.LinkedList;
     
    910
    1011import javax.xml.parsers.DocumentBuilderFactory;
     12import javax.xml.parsers.ParserConfigurationException;
    1113import javax.xml.xpath.XPath;
    1214import javax.xml.xpath.XPathConstants;
     
    2325import org.w3c.dom.Node;
    2426import org.w3c.dom.NodeList;
     27import org.xml.sax.SAXException;
    2528
    2629public class OsmServerUserInfoReader extends OsmServerReader {
     
    178181        } catch (OsmTransferException e) {
    179182            throw e;
    180         } catch (Exception e) {
     183        } catch (IOException | ParserConfigurationException | SAXException e) {
    181184            throw new OsmTransferException(e);
    182185        } finally {
  • trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java

    r9171 r10212  
    1919import javax.xml.parsers.DocumentBuilder;
    2020import javax.xml.parsers.DocumentBuilderFactory;
     21import javax.xml.parsers.ParserConfigurationException;
    2122
    2223import org.openstreetmap.josm.Main;
     
    142143            builderFactory.setValidating(false);
    143144            builderFactory.setNamespaceAware(true);
    144             DocumentBuilder builder = null;
    145             builder = builderFactory.newDocumentBuilder();
     145            DocumentBuilder builder = builderFactory.newDocumentBuilder();
    146146            builder.setEntityResolver(new EntityResolver() {
    147147                @Override
     
    151151                }
    152152            });
    153             Document document = null;
    154             document = builder.parse(new InputSource(new StringReader(incomingData)));
     153            Document document = builder.parse(new InputSource(new StringReader(incomingData)));
    155154
    156155            // Some WMS service URLs specify a different base URL for their GetMap service
     
    193192            List<Element> children = getChildren(capabilityElem, "Layer");
    194193            layers = parseLayers(children, new HashSet<String>());
    195         } catch (Exception e) {
     194        } catch (MalformedURLException | ParserConfigurationException | SAXException e) {
    196195            throw new WMSGetCapabilitiesException(e, incomingData);
    197196        }
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/RemoteControlHttpServer.java

    r9078 r10212  
    3636            instance4 = new RemoteControlHttpServer(port, false);
    3737            instance4.start();
    38         } catch (Exception ex) {
     38        } catch (IOException ex) {
    3939            Main.warn(marktr("Cannot start IPv4 remotecontrol server on port {0}: {1}"),
    4040                    Integer.toString(port), ex.getLocalizedMessage());
     
    4343            instance6 = new RemoteControlHttpServer(port, true);
    4444            instance6.start();
    45         } catch (Exception ex) {
     45        } catch (IOException ex) {
    4646            /* only show error when we also have no IPv4 */
    4747            if (instance4 == null) {
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/RemoteControlHttpsServer.java

    r10060 r10212  
    333333                instance4 = new RemoteControlHttpsServer(port, false);
    334334                instance4.start();
    335             } catch (Exception ex) {
     335            } catch (IOException | GeneralSecurityException ex) {
    336336                Main.warn(marktr("Cannot start IPv4 remotecontrol https server on port {0}: {1}"),
    337337                        Integer.toString(port), ex.getLocalizedMessage());
     
    340340                instance6 = new RemoteControlHttpsServer(port, true);
    341341                instance6.start();
    342             } catch (Exception ex) {
     342            } catch (IOException | GeneralSecurityException ex) {
    343343                /* only show error when we also have no IPv4 */
    344344                if (instance4 == null) {
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandler.java

    r9732 r10212  
    4747                }
    4848            }
    49         } catch (Exception ex) {
     49        } catch (RuntimeException ex) {
    5050            Main.warn("RemoteControl: Error parsing import remote control request:");
    5151            Main.error(ex);
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java

    r10131 r10212  
    145145                }
    146146            }
    147         } catch (Exception ex) {
     147        } catch (RuntimeException ex) {
    148148            Main.warn("RemoteControl: Error parsing load_and_zoom remote control request:");
    149149            Main.error(ex);
  • trunk/src/org/openstreetmap/josm/io/session/SessionWriter.java

    r9746 r10212  
    99import java.io.OutputStream;
    1010import java.io.OutputStreamWriter;
    11 import java.lang.reflect.Constructor;
    1211import java.nio.charset.StandardCharsets;
    1312import java.util.ArrayList;
     
    9796            return null;
    9897        try {
    99             Constructor<? extends SessionLayerExporter> constructor = exporterClass.getConstructor(layerClass);
    100             return constructor.newInstance(layer);
    101         } catch (Exception e) {
     98            return exporterClass.getConstructor(layerClass).newInstance(layer);
     99        } catch (ReflectiveOperationException e) {
    102100            throw new RuntimeException(e);
    103101        }
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r10179 r10212  
    1515import java.io.File;
    1616import java.io.FilenameFilter;
     17import java.io.IOException;
    1718import java.net.URL;
    1819import java.net.URLClassLoader;
     
    723724                        + "Delete from preferences?</html>", plugin.name, plugin.className);
    724725            }
    725         }  catch (Exception e) {
     726        }  catch (RuntimeException e) {
    726727            pluginLoadingExceptions.put(plugin.name, e);
    727728            Main.error(e);
     
    11931194                // Check the plugin is a valid and accessible JAR file before installing it (fix #7754)
    11941195                new JarFile(updatedPlugin).close();
    1195             } catch (Exception e) {
     1196            } catch (IOException e) {
    11961197                if (dowarn) {
    11971198                    Main.warn(tr("Failed to install plugin ''{0}'' from temporary download file ''{1}''. {2}",
     
    12211222            try {
    12221223                new JarFile(jar).close();
    1223             } catch (Exception e) {
     1224            } catch (IOException e) {
    12241225                Main.warn(e);
    12251226                return false;
  • trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java

    r9983 r10212  
    273273                        }
    274274                    }
    275                 } catch (Exception e) {
     275                } catch (NumberFormatException e) {
    276276                    Main.error(e);
    277277                }
  • trunk/src/org/openstreetmap/josm/plugins/PluginProxy.java

    r10055 r10212  
    22package org.openstreetmap.josm.plugins;
    33
     4import java.lang.reflect.InvocationTargetException;
    45import java.util.List;
    56
     
    4546        } catch (NoSuchMethodException e) {
    4647            Main.debug("Plugin "+plugin+" does not define mapFrameInitialized");
    47         } catch (Exception e) {
     48        } catch (InvocationTargetException | IllegalAccessException | IllegalArgumentException e) {
    4849            handlePluginException(e);
    4950        }
     
    5758            Main.debug("Plugin "+plugin+" does not define getPreferenceSetting");
    5859            return null;
    59         } catch (Exception e) {
     60        } catch (InvocationTargetException | IllegalAccessException | IllegalArgumentException e) {
    6061            handlePluginException(e);
    6162        }
     
    6970        } catch (NoSuchMethodException e) {
    7071            Main.debug("Plugin "+plugin+" does not define addDownloadSelection");
    71         } catch (Exception e) {
     72        } catch (InvocationTargetException | IllegalAccessException | IllegalArgumentException e) {
    7273            handlePluginException(e);
    7374        }
  • trunk/src/org/openstreetmap/josm/tools/AudioPlayer.java

    r9814 r10212  
    207207            audioPlayer = new AudioPlayer();
    208208            return audioPlayer;
    209         } catch (Exception ex) {
     209        } catch (RuntimeException ex) {
    210210            Main.error(ex);
    211211            return null;
     
    249249        AudioInputStream audioInputStream = null;
    250250        SourceDataLine audioOutputLine = null;
    251         AudioFormat audioFormat = null;
     251        AudioFormat audioFormat;
    252252        byte[] abData = new byte[(int) chunk];
    253253
     
    266266                        command.possiblyInterrupt();
    267267                        for (;;) {
    268                             int nBytesRead = 0;
     268                            int nBytesRead;
    269269                            nBytesRead = audioInputStream.read(abData, 0, abData.length);
    270270                            position += nBytesRead / bytesPerSecond;
     
    362362                    command.failed(startPlayingException); // sets state
    363363                }
    364             } catch (Exception e) {
     364            } catch (IOException e) {
    365365                state = State.NOTPLAYING;
     366                Main.error(e);
    366367            }
    367368        }
  • trunk/src/org/openstreetmap/josm/tools/ExifReader.java

    r9970 r10212  
    7878                return date;
    7979            }
    80         } catch (Exception e) {
     80        } catch (UncheckedParseException | JpegProcessingException | IOException e) {
    8181            Main.error(e);
    8282        }
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r10179 r10212  
    8383
    8484import com.kitfox.svg.SVGDiagram;
     85import com.kitfox.svg.SVGException;
    8586import com.kitfox.svg.SVGUniverse;
    8687
     
    986987                }
    987988            }
    988         } catch (Exception e) {
     989        } catch (IOException e) {
    989990            Main.warn(tr("Failed to handle zip file ''{0}''. Exception was: {1}", archive.getName(), e.toString()));
    990991        }
     
    11531154        } catch (SAXReturnException r) {
    11541155            return r.getResult();
    1155         } catch (Exception e) {
     1156        } catch (IOException | SAXException e) {
    11561157            Main.warn("Parsing " + base + fn + " failed:\n" + e);
    11571158            return null;
     
    14271428                svg.render(g);
    14281429            }
    1429         } catch (Exception ex) {
     1430        } catch (SVGException ex) {
    14301431            Main.error("Unable to load svg: {0}", ex.getMessage());
    14311432            return null;
  • trunk/src/org/openstreetmap/josm/tools/OpenBrowser.java

    r8540 r10212  
    77import java.io.IOException;
    88import java.net.URI;
     9import java.net.URISyntaxException;
    910
    1011import org.openstreetmap.josm.Main;
     
    6263                    }
    6364                }
    64             } catch (Exception e) {
     65            } catch (IOException e) {
    6566                Main.warn(e);
    6667                return e.getMessage();
     
    8889        try {
    8990            return displayUrl(new URI(url));
    90         } catch (Exception e) {
     91        } catch (URISyntaxException e) {
    9192            return e.getMessage();
    9293        }
  • trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java

    r10208 r10212  
    88import java.io.Reader;
    99import java.lang.reflect.Field;
     10import java.lang.reflect.InvocationTargetException;
    1011import java.lang.reflect.Method;
    1112import java.lang.reflect.Modifier;
     
    156157                    }
    157158                }
    158             } catch (Exception e) {
     159            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
    159160                Main.error(e); // SAXException does not dump inner exceptions.
    160161                throwException(e);
  • trunk/src/org/openstreetmap/josm/tools/bugreport/BugReportExceptionHandler.java

    r10067 r10212  
    144144                    JPanel p = buildPanel(e);
    145145                    JOptionPane.showMessageDialog(Main.parent, p, tr("You have encountered a bug in JOSM"), JOptionPane.ERROR_MESSAGE);
    146                 } catch (Exception ex) {
     146                } catch (RuntimeException ex) {
    147147                    Main.error(ex);
    148148                }
  • trunk/src/org/openstreetmap/josm/tools/date/DateUtils.java

    r10133 r10212  
    136136        try {
    137137            return XML_DATE.newXMLGregorianCalendar(str).toGregorianCalendar().getTimeInMillis();
    138         } catch (Exception ex) {
     138        } catch (IllegalArgumentException ex) {
    139139            throw new UncheckedParseException("The date string (" + str + ") could not be parsed.", ex);
    140140        }
Note: See TracChangeset for help on using the changeset viewer.