Changeset 11746 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2017-03-19T02:26:34+01:00 (7 years ago)
Author:
Don-vip
Message:

PMD - Strict Exceptions

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

Legend:

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

    r11731 r11746  
    11271127                findBoundaryPolygonsStartingWith(discardedResult, traverser, result, startWay);
    11281128            }
    1129         } catch (Throwable t) {
     1129        } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException t) {
    11301130            throw BugReport.intercept(t).put("traverser", traverser);
    11311131        }
     
    11831183                }
    11841184            }
    1185         } catch (Throwable t) {
     1185        } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException t) {
    11861186            throw BugReport.intercept(t).put("path", path);
    11871187        }
  • trunk/src/org/openstreetmap/josm/actions/SessionLoadAction.java

    r11645 r11746  
    3131import org.openstreetmap.josm.io.session.SessionReader;
    3232import org.openstreetmap.josm.tools.CheckParameterUtil;
     33import org.openstreetmap.josm.tools.JosmRuntimeException;
    3334import org.openstreetmap.josm.tools.Utils;
    3435
     
    178179            } catch (IOException e) {
    179180                handleException(tr("IO Error"), e);
    180             } catch (RuntimeException e) {
     181            } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    181182                cancel();
    182183                throw e;
  • trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java

    r11650 r11746  
    269269        String reportHeader = getReportHeader();
    270270        text.append(reportHeader);
    271         try {
    272             Map<String, Setting<?>> settings = Main.pref.getAllSettings();
    273             Set<String> keys = new HashSet<>(settings.keySet());
    274             for (String key : keys) {
    275                 // Remove sensitive information from status report
    276                 if (key.startsWith("marker.show") || key.contains("username") || key.contains("password") || key.contains("access-token")) {
    277                     settings.remove(key);
    278                 }
    279             }
    280             for (Entry<String, Setting<?>> entry : settings.entrySet()) {
    281                 text.append(paramCleanup(entry.getKey()))
    282                     .append('=')
    283                     .append(paramCleanup(entry.getValue().getValue().toString())).append('\n');
    284             }
    285         } catch (Exception ex) {
    286             Main.error(ex);
     271        Map<String, Setting<?>> settings = Main.pref.getAllSettings();
     272        Set<String> keys = new HashSet<>(settings.keySet());
     273        for (String key : keys) {
     274            // Remove sensitive information from status report
     275            if (key.startsWith("marker.show") || key.contains("username") || key.contains("password") || key.contains("access-token")) {
     276                settings.remove(key);
     277            }
     278        }
     279        for (Entry<String, Setting<?>> entry : settings.entrySet()) {
     280            text.append(paramCleanup(entry.getKey()))
     281                .append('=')
     282                .append(paramCleanup(entry.getValue().getValue().toString())).append('\n');
    287283        }
    288284
  • trunk/src/org/openstreetmap/josm/actions/audio/AudioBackAction.java

    r6380 r11746  
    88import java.awt.event.ActionEvent;
    99import java.awt.event.KeyEvent;
     10import java.io.IOException;
    1011
    1112import org.openstreetmap.josm.Main;
     
    3839            else
    3940                MarkerLayer.playAudio();
    40         } catch (Exception ex) {
     41        } catch (IOException | InterruptedException ex) {
    4142            AudioPlayer.audioMalfunction(ex);
    4243        }
  • trunk/src/org/openstreetmap/josm/actions/audio/AudioFastSlowAction.java

    r8444 r11746  
    33
    44import java.awt.event.ActionEvent;
     5import java.io.IOException;
    56
    67import org.openstreetmap.josm.Main;
     
    4142            if (AudioPlayer.playing() || AudioPlayer.paused())
    4243                AudioPlayer.play(AudioPlayer.url(), AudioPlayer.position(), speed * multiplier);
    43         } catch (Exception ex) {
     44        } catch (IOException | InterruptedException ex) {
    4445            AudioPlayer.audioMalfunction(ex);
    4546        }
  • trunk/src/org/openstreetmap/josm/actions/audio/AudioFwdAction.java

    r6380 r11746  
    77import java.awt.event.ActionEvent;
    88import java.awt.event.KeyEvent;
     9import java.io.IOException;
    910
    1011import org.openstreetmap.josm.Main;
     
    3637            else
    3738                MarkerLayer.playAudio();
    38         } catch (Exception ex) {
     39        } catch (IOException | InterruptedException ex) {
    3940            AudioPlayer.audioMalfunction(ex);
    4041        }
  • trunk/src/org/openstreetmap/josm/actions/audio/AudioPlayPauseAction.java

    r11452 r11746  
    77import java.awt.event.ActionEvent;
    88import java.awt.event.KeyEvent;
     9import java.io.IOException;
    910import java.net.URL;
    1011
     
    5354                }
    5455            }
    55         } catch (Exception ex) {
     56        } catch (IOException | InterruptedException ex) {
    5657            AudioPlayer.audioMalfunction(ex);
    5758        }
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmChangeTask.java

    r10463 r11746  
    1111import java.util.Map.Entry;
    1212import java.util.concurrent.Future;
     13import java.util.concurrent.RejectedExecutionException;
    1314import java.util.regex.Matcher;
    1415import java.util.regex.Pattern;
     
    115116                // Let's load all required history
    116117                Main.worker.submit(new HistoryLoaderAndListener(toLoad));
    117             } catch (Exception e) {
     118            } catch (RejectedExecutionException e) {
    118119                rememberException(e);
    119120                setFailed(true);
  • trunk/src/org/openstreetmap/josm/data/AutosaveTask.java

    r11288 r11746  
    233233                    GuiHelper.runInEDT(this::displayNotification);
    234234                }
    235             } catch (RuntimeException t) {
     235            } catch (RuntimeException t) { // NOPMD
    236236                // Don't let exception stop time thread
    237237                Main.error("Autosave failed:");
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r11728 r11746  
    14201420                Utils.setObjectsAccessible(field);
    14211421                field.set(null, ResourceBundle.getBundle("sun.awt.resources.awt"));
    1422             } catch (ReflectiveOperationException | RuntimeException e) {
     1422            } catch (ReflectiveOperationException | RuntimeException e) { // NOPMD
     1423                // Catch RuntimeException in order to catch InaccessibleObjectException, new in Java 9
    14231424                Main.warn(e);
    14241425            }
  • trunk/src/org/openstreetmap/josm/data/cache/JCSCacheManager.java

    r11400 r11746  
    182182            } catch (IOException e) {
    183183                throw e;
    184             } catch (Exception e) {
     184            } catch (Exception e) { // NOPMD
    185185                throw new IOException(e);
    186186            }
  • trunk/src/org/openstreetmap/josm/data/osm/DatasetConsistencyTest.java

    r10627 r11746  
    99
    1010import org.openstreetmap.josm.Main;
     11import org.openstreetmap.josm.tools.JosmRuntimeException;
    1112import org.openstreetmap.josm.tools.Utils;
    1213
     
    212213            }
    213214
    214         } catch (RuntimeException e) {
     215        } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    215216            writer.println("Exception during dataset integrity test:");
    216217            e.printStackTrace(writer);
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java

    r11731 r11746  
    8686import org.openstreetmap.josm.tools.Geometry.AreaAndPerimeter;
    8787import org.openstreetmap.josm.tools.ImageProvider;
     88import org.openstreetmap.josm.tools.JosmRuntimeException;
    8889import org.openstreetmap.josm.tools.Utils;
    8990import org.openstreetmap.josm.tools.bugreport.BugReport;
     
    17351736                }
    17361737                return output;
    1737             } catch (RuntimeException e) {
     1738            } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    17381739                throw BugReport.intercept(e).put("input-size", input.size()).put("output-size", output.size());
    17391740            } finally {
     
    17471748                    osm.accept(this);
    17481749                }
    1749             } catch (RuntimeException e) {
     1750            } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    17501751                throw BugReport.intercept(e).put("osm", osm);
    17511752            }
     
    18551856
    18561857            benchmark.renderDone();
    1857         } catch (RuntimeException e) {
     1858        } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    18581859            throw BugReport.intercept(e)
    18591860                    .put("data", data)
     
    18701871        try {
    18711872            record.paintPrimitive(paintSettings, this);
    1872         } catch (RuntimeException e) {
     1873        } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    18731874            throw BugReport.intercept(e).put("record", record);
    18741875        }
  • trunk/src/org/openstreetmap/josm/data/preferences/PreferencesWriter.java

    r11553 r11746  
    8888            addDefaults();
    8989        } else {
    90             throw new NullPointerException();
     90            throw new IllegalArgumentException(setting.toString());
    9191        }
    9292    }
     
    105105            addDefaults();
    106106        } else {
    107             throw new NullPointerException();
     107            throw new IllegalArgumentException(setting.toString());
    108108        }
    109109    }
     
    126126            addDefaults();
    127127        } else {
    128             throw new NullPointerException();
     128            throw new IllegalArgumentException(setting.toString());
    129129        }
    130130    }
     
    147147            addDefaults();
    148148        } else {
    149             throw new NullPointerException();
     149            throw new IllegalArgumentException(setting.toString());
    150150        }
    151151    }
  • trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java

    r11553 r11746  
    3232import org.openstreetmap.josm.data.projection.proj.Proj;
    3333import org.openstreetmap.josm.data.projection.proj.ProjParameters;
     34import org.openstreetmap.josm.tools.JosmRuntimeException;
    3435import org.openstreetmap.josm.tools.Utils;
    3536import org.openstreetmap.josm.tools.bugreport.BugReport;
     
    831832                        }
    832833                    }
    833                 } catch (RuntimeException e) {
     834                } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    834835                    Main.error(e);
    835836                }
  • trunk/src/org/openstreetmap/josm/data/projection/Projections.java

    r11642 r11746  
    338338            try {
    339339                proj = pc.getProjection();
    340             } catch (RuntimeException e) {
     340            } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    341341                Main.warn(e, "Unable to get projection "+code+" with "+pc+':');
    342342            }
  • trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java

    r11594 r11746  
    333333                    test.initialize();
    334334                }
    335             } catch (Exception e) {
     335            } catch (Exception e) { // NOPMD
    336336                Main.error(e);
    337337                if (!GraphicsEnvironment.isHeadless()) {
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r11385 r11746  
    271271                for (TaggingPresetItem i : p.data) {
    272272                    if (i instanceof KeyedItem) {
    273                         addPresetValue(p, (KeyedItem) i);
     273                        addPresetValue((KeyedItem) i);
    274274                    } else if (i instanceof CheckGroup) {
    275275                        for (Check c : ((CheckGroup) i).checks) {
    276                             addPresetValue(p, c);
     276                            addPresetValue(c);
    277277                        }
    278278                    }
     
    282282    }
    283283
    284     private static void addPresetValue(TaggingPreset p, KeyedItem ky) {
     284    private static void addPresetValue(KeyedItem ky) {
    285285        Collection<String> values = ky.getValues();
    286286        if (ky.key != null && values != null) {
    287             try {
    288                 presetsValueData.putAll(ky.key, values);
    289                 harmonizedKeys.put(harmonizeKey(ky.key), ky.key);
    290             } catch (NullPointerException e) {
    291                 Main.error(e, p+": Unable to initialize "+ky+'.');
    292             }
     287            presetsValueData.putAll(ky.key, values);
     288            harmonizedKeys.put(harmonizeKey(ky.key), ky.key);
    293289        }
    294290    }
     
    543539
    544540    private static String harmonizeKey(String key) {
    545         key = key.toLowerCase(Locale.ENGLISH).replace('-', '_').replace(':', '_').replace(' ', '_');
    546         return Utils.strip(key, "-_;:,");
     541        return Utils.strip(key.toLowerCase(Locale.ENGLISH).replace('-', '_').replace(':', '_').replace(' ', '_'), "-_;:,");
    547542    }
    548543
    549544    private static String harmonizeValue(String value) {
    550         value = value.toLowerCase(Locale.ENGLISH).replace('-', '_').replace(' ', '_');
    551         return Utils.strip(value, "-_;:,");
     545        return Utils.strip(value.toLowerCase(Locale.ENGLISH).replace('-', '_').replace(' ', '_'), "-_;:,");
    552546    }
    553547
  • trunk/src/org/openstreetmap/josm/gui/JosmUserIdentityManager.java

    r11739 r11746  
    2020import org.openstreetmap.josm.io.auth.CredentialsManager;
    2121import org.openstreetmap.josm.tools.CheckParameterUtil;
     22import org.openstreetmap.josm.tools.JosmRuntimeException;
    2223
    2324/**
     
    6667                try {
    6768                    instance.initFromOAuth();
    68                 } catch (RuntimeException e) {
     69                } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    6970                    Main.error(e);
    7071                    // Fall back to preferences if OAuth identification fails for any reason
  • trunk/src/org/openstreetmap/josm/gui/MapStatus.java

    r11620 r11746  
    10781078            try {
    10791079                thread.interrupt();
    1080             } catch (RuntimeException e) {
     1080            } catch (SecurityException e) {
    10811081                Main.error(e);
    10821082            }
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r11713 r11746  
    7171import org.openstreetmap.josm.gui.layer.markerlayer.PlayHeadMarker;
    7272import org.openstreetmap.josm.tools.AudioPlayer;
     73import org.openstreetmap.josm.tools.JosmRuntimeException;
    7374import org.openstreetmap.josm.tools.Shortcut;
    7475import org.openstreetmap.josm.tools.Utils;
     
    354355                repaint();
    355356            }
    356         } catch (RuntimeException t) {
     357        } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException t) {
    357358            throw BugReport.intercept(t).put("layer", e.getAddedLayer());
    358359        }
     
    453454            painter.paint(paintGraphics);
    454455            g.setPaintMode();
    455         } catch (RuntimeException t) {
     456        } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException t) {
    456457            BugReport.intercept(t).put("layer", layer).warn();
    457458        }
     
    467468                return;
    468469            }
    469         } catch (RuntimeException e) {
     470        } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    470471            BugReport.intercept(e).put("center", this::getCenter).warn();
    471472            return;
     
    537538        try {
    538539            drawTemporaryLayers(tempG, getLatLonBounds(g.getClipBounds()));
    539         } catch (RuntimeException e) {
     540        } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    540541            BugReport.intercept(e).put("temporaryLayers", temporaryLayers).warn();
    541542        }
     
    544545        try {
    545546            drawWorldBorders(tempG);
    546         } catch (RuntimeException e) {
     547        } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    547548            // getProjection() needs to be inside lambda to catch errors.
    548549            BugReport.intercept(e).put("bounds", () -> getProjection().getWorldBoundsLatLon()).warn();
     
    593594                try {
    594595                    mvp.paint(tempG, this, box);
    595                 } catch (RuntimeException e) {
     596                } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    596597                    throw BugReport.intercept(e).put("mvp", mvp);
    597598                }
  • trunk/src/org/openstreetmap/josm/gui/MapViewState.java

    r11553 r11746  
    2727import org.openstreetmap.josm.tools.CheckParameterUtil;
    2828import org.openstreetmap.josm.tools.Geometry;
     29import org.openstreetmap.josm.tools.JosmRuntimeException;
    2930import org.openstreetmap.josm.tools.bugreport.BugReport;
    3031
     
    145146        try {
    146147            return position.getLocationOnScreen();
    147         } catch (RuntimeException e) {
     148        } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    148149            throw BugReport.intercept(e).put("position", position).put("parent", position::getParent);
    149150        }
     
    197198        try {
    198199            return getPointFor(node.getEastNorth(getProjection()));
    199         } catch (RuntimeException e) {
     200        } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    200201            throw BugReport.intercept(e).put("node", node);
    201202        }
  • trunk/src/org/openstreetmap/josm/gui/PleaseWaitRunnable.java

    r10611 r11746  
    1515import org.openstreetmap.josm.io.OsmTransferException;
    1616import org.openstreetmap.josm.tools.CheckParameterUtil;
     17import org.openstreetmap.josm.tools.JosmRuntimeException;
    1718import org.openstreetmap.josm.tools.bugreport.BugReportExceptionHandler;
    1819import org.xml.sax.SAXException;
     
    112113                }
    113114            }
    114         } catch (final RuntimeException |
     115        } catch (final JosmRuntimeException | IllegalArgumentException | IllegalStateException |
    115116                OsmTransferException | IOException | SAXException | InvocationTargetException | InterruptedException e) {
    116117            if (!ignoreException) {
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/AbstractStackTransferHandler.java

    r10936 r11746  
    1414import org.openstreetmap.josm.gui.datatransfer.importers.AbstractOsmDataPaster;
    1515import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     16import org.openstreetmap.josm.tools.JosmRuntimeException;
    1617import org.openstreetmap.josm.tools.bugreport.BugReport;
    1718
     
    5859                } catch (UnsupportedFlavorException | IOException e) {
    5960                    Main.warn(e);
    60                 } catch (RuntimeException e) {
     61                } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    6162                    BugReport.intercept(e).put("paster", df).put("flavors", support::getDataFlavors).warn();
    6263                }
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/ClipboardUtils.java

    r11535 r11746  
    116116                    Thread.currentThread().interrupt();
    117117                }
    118             } catch (NullPointerException e) {
     118            } catch (NullPointerException e) { // NOPMD
    119119                // JDK-6322854: On Linux/X11, NPE can happen for unknown reasons, on all versions of Java
    120120                Main.error(e);
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/OsmTransferHandler.java

    r11554 r11746  
    9797        } catch (IllegalStateException e) {
    9898            Main.debug(e);
    99         } catch (NullPointerException e) {
     99        } catch (NullPointerException e) { // NOPMD
    100100            // JDK-6322854: On Linux/X11, NPE can happen for unknown reasons, on all versions of Java
    101101            Main.error(e);
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/importers/PrimitiveDataPaster.java

    r10868 r11746  
    2626import org.openstreetmap.josm.gui.datatransfer.data.PrimitiveTransferData;
    2727import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     28import org.openstreetmap.josm.tools.JosmRuntimeException;
    2829import org.openstreetmap.josm.tools.bugreport.BugReport;
    2930
     
    7778                    updateMembers(newIds, data);
    7879                }
    79             } catch (RuntimeException e) {
     80            } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    8081                throw BugReport.intercept(e).put("data", data);
    8182            }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/DialogsPanel.java

    r11452 r11746  
    1717import org.openstreetmap.josm.tools.CheckParameterUtil;
    1818import org.openstreetmap.josm.tools.Destroyable;
     19import org.openstreetmap.josm.tools.JosmRuntimeException;
    1920import org.openstreetmap.josm.tools.bugreport.BugReport;
    2021
     
    325326            try {
    326327                t.destroy();
    327             } catch (RuntimeException e) {
     328            } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    328329                throw BugReport.intercept(e).put("dialog", t).put("dialog-class", t.getClass());
    329330            }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentPanel.java

    r10938 r11746  
    5454import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
    5555import org.openstreetmap.josm.tools.ImageProvider;
     56import org.openstreetmap.josm.tools.JosmRuntimeException;
    5657import org.openstreetmap.josm.tools.bugreport.BugReportExceptionHandler;
    5758
     
    235236                        GuiHelper.runInEDT(() -> HistoryBrowserDialogManager.getInstance().show(h));
    236237                    }
    237                 } catch (final RuntimeException e) {
     238                } catch (final JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    238239                    GuiHelper.runInEDT(() -> BugReportExceptionHandler.handleException(e));
    239240                }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java

    r11684 r11746  
    4646import org.openstreetmap.josm.gui.util.GuiHelper;
    4747import org.openstreetmap.josm.gui.widgets.OsmPrimitivesTableModel;
     48import org.openstreetmap.josm.tools.JosmRuntimeException;
    4849import org.openstreetmap.josm.tools.bugreport.BugReport;
    4950
     
    808809            }
    809810            return connectionType.get(i);
    810         } catch (RuntimeException e) {
     811        } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    811812            throw BugReport.intercept(e).put("i", i).put("members", members).put("relation", relation);
    812813        }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculator.java

    r11452 r11746  
    1313import org.openstreetmap.josm.data.osm.Way;
    1414import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionType.Direction;
     15import org.openstreetmap.josm.tools.JosmRuntimeException;
    1516import org.openstreetmap.josm.tools.bugreport.BugReport;
    1617
     
    4445            try {
    4546                lastWct = updateLinksFor(con, lastWct, i);
    46             } catch (RuntimeException e) {
     47            } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    4748                int index = i;
    4849                throw BugReport.intercept(e).put("i", i).put("member", () -> members.get(index)).put("con", con);
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java

    r11461 r11746  
    2727import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent;
    2828import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;
     29import org.openstreetmap.josm.tools.JosmRuntimeException;
    2930import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    3031import org.openstreetmap.josm.tools.WindowGeometry;
     
    224225                    SwingUtilities.invokeLater(() -> show(h));
    225226                }
    226             } catch (final RuntimeException e) {
     227            } catch (final JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    227228                BugReportExceptionHandler.handleException(e);
    228229            }
  • trunk/src/org/openstreetmap/josm/gui/io/SaveLayerTask.java

    r11553 r11746  
    1111import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    1212import org.openstreetmap.josm.tools.CheckParameterUtil;
     13import org.openstreetmap.josm.tools.JosmRuntimeException;
    1314
    1415/**
     
    5556                layerInfo.getLayer().onPostSaveToFile();
    5657            }
    57         } catch (RuntimeException e) {
     58        } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    5859            Main.error(e);
    5960            setLastException(e);
  • trunk/src/org/openstreetmap/josm/gui/layer/LayerManager.java

    r11297 r11746  
    1414import org.openstreetmap.josm.Main;
    1515import org.openstreetmap.josm.gui.util.GuiHelper;
     16import org.openstreetmap.josm.tools.JosmRuntimeException;
    1617import org.openstreetmap.josm.tools.Utils;
    1718import org.openstreetmap.josm.tools.bugreport.BugReport;
     
    404405            try {
    405406                l.layerAdded(e);
    406             } catch (RuntimeException t) {
     407            } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException t) {
    407408                throw BugReport.intercept(t).put("listener", l).put("event", e);
    408409            }
     
    421422            try {
    422423                l.layerRemoving(e);
    423             } catch (RuntimeException t) {
     424            } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException t) {
    424425                throw BugReport.intercept(t).put("listener", l).put("event", e).put("layer", layer);
    425426            }
     
    434435            try {
    435436                l.layerOrderChanged(e);
    436             } catch (RuntimeException t) {
     437            } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException t) {
    437438                throw BugReport.intercept(t).put("listener", l).put("event", e);
    438439            }
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java

    r11739 r11746  
    8383import org.openstreetmap.josm.tools.GBC;
    8484import org.openstreetmap.josm.tools.ImageProvider;
     85import org.openstreetmap.josm.tools.JosmRuntimeException;
    8586import org.openstreetmap.josm.tools.Pair;
    8687import org.openstreetmap.josm.tools.Utils;
     
    934935                final long deciSeconds = timezoneOffsetPair.b.getMilliseconds() / 100;
    935936                sldSeconds.setValue((int) (deciSeconds % 60));
    936             } catch (RuntimeException e) {
     937            } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    937938                Main.warn(e);
    938939                JOptionPane.showMessageDialog(Main.parent,
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java

    r11745 r11746  
    1212import org.openstreetmap.josm.data.coor.LatLon;
    1313import org.openstreetmap.josm.tools.ExifReader;
     14import org.openstreetmap.josm.tools.JosmRuntimeException;
    1415
    1516import com.drew.imaging.jpeg.JpegMetadataReader;
     
    450451        try {
    451452            setExifTime(ExifReader.readTime(metadata));
    452         } catch (RuntimeException ex) {
     453        } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException ex) {
    453454            Main.warn(ex);
    454455            setExifTime(null);
  • trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileSourceDisplaySettings.java

    r10603 r11746  
    1111import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer;
    1212import org.openstreetmap.josm.tools.CheckParameterUtil;
     13import org.openstreetmap.josm.tools.JosmRuntimeException;
    1314import org.openstreetmap.josm.tools.bugreport.BugReport;
    1415
     
    275276                setDisplacement(new EastNorth(Double.parseDouble(dx), Double.parseDouble(dy)));
    276277            }
    277         } catch (RuntimeException e) {
     278        } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    278279            throw BugReport.intercept(e).put("data", data);
    279280        }
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/AudioMarker.java

    r9078 r11746  
    33
    44import java.awt.event.ActionEvent;
     5import java.io.IOException;
    56import java.net.URL;
    67import java.util.Collections;
     
    5859            AudioPlayer.play(audioUrl, offset + syncOffset + after);
    5960            recentlyPlayedMarker = this;
    60         } catch (Exception e) {
     61        } catch (IOException | InterruptedException e) {
    6162            AudioPlayer.audioMalfunction(e);
    6263        }
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java

    r11381 r11746  
    99import java.awt.event.MouseAdapter;
    1010import java.awt.event.MouseEvent;
     11import java.io.IOException;
    1112
    1213import javax.swing.JOptionPane;
     
    9899            try {
    99100                AudioPlayer.pause();
    100             } catch (Exception ex) {
     101            } catch (IOException | InterruptedException ex) {
    101102                AudioPlayer.audioMalfunction(ex);
    102103            }
     
    112113            try {
    113114                AudioPlayer.pause();
    114             } catch (Exception ex) {
     115            } catch (IOException | InterruptedException ex) {
    115116                AudioPlayer.audioMalfunction(ex);
    116117            }
  • trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java

    r11397 r11746  
    599599                } catch (SecurityException ex) {
    600600                    Main.error(ex);
    601                 } catch (RuntimeException ex) {
     601                } catch (RuntimeException ex) { // NOPMD
    602602                    // allow to change most settings even if e.g. a plugin fails
    603603                    BugReportExceptionHandler.handleException(ex);
     
    616616            } catch (SecurityException ex) {
    617617                Main.error(ex);
    618             } catch (RuntimeException ex) {
     618            } catch (RuntimeException ex) { // NOPMD
    619619                BugReportExceptionHandler.handleException(ex);
    620620            } finally {
  • trunk/src/org/openstreetmap/josm/gui/preferences/map/MapPaintPreference.java

    r11493 r11746  
    165165                return css.title;
    166166            }
    167         } catch (RuntimeException ignore) {
     167        } catch (RuntimeException ignore) { // NOPMD
    168168            Main.debug(ignore);
    169169        }
  • trunk/src/org/openstreetmap/josm/gui/progress/PleaseWaitProgressMonitor.java

    r11673 r11746  
    6666            try {
    6767                runnable.run();
    68             } catch (RuntimeException e) {
     68            } catch (RuntimeException e) { // NOPMD
    6969                throw BugReport.intercept(e).put("monitor", this);
    7070            }
  • trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionManager.java

    r11452 r11746  
    1515import java.util.function.Function;
    1616
    17 import org.openstreetmap.josm.Main;
    1817import org.openstreetmap.josm.data.osm.DataSet;
    1918import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    219218            KeyedItem ki = (KeyedItem) item;
    220219            if (ki.key != null && ki.getValues() != null) {
    221                 try {
    222                     PRESET_TAG_CACHE.putAll(ki.key, ki.getValues());
    223                 } catch (NullPointerException e) {
    224                     Main.error(e, p + ": Unable to cache " + ki);
    225                 }
     220                PRESET_TAG_CACHE.putAll(ki.key, ki.getValues());
    226221            }
    227222        } else if (item instanceof Roles) {
  • trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java

    r11381 r11746  
    159159            try {
    160160                return callable.call();
    161             } catch (Exception e) {
     161            } catch (Exception e) { // NOPMD
    162162                Main.error(e);
    163163                return null;
  • trunk/src/org/openstreetmap/josm/gui/widgets/JosmPasswordField.java

    r10627 r11746  
    125125                    try {
    126126                        pasteAction.actionPerformed(e);
    127                     } catch (NullPointerException npe) {
     127                    } catch (NullPointerException npe) { // NOPMD
    128128                        Main.error(npe, "NullPointerException occured because of JDK bug 6322854. "
    129129                                +"Copy/Paste operation has not been performed. Please complain to Oracle: "+
  • trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java

    r11397 r11746  
    1717import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    1818import org.openstreetmap.josm.tools.CheckParameterUtil;
     19import org.openstreetmap.josm.tools.JosmRuntimeException;
    1920import org.xml.sax.SAXException;
    2021
     
    114115        } catch (OsmTransferException e) {
    115116            throw e;
    116         } catch (RuntimeException e) {
     117        } catch (JosmRuntimeException | IllegalStateException e) {
    117118            if (cancel)
    118119                return null;
  • trunk/src/org/openstreetmap/josm/io/NameFinder.java

    r11620 r11746  
    241241                Main.error(ex); // SAXException does not chain correctly
    242242                throw new SAXException(ex.getMessage(), ex);
    243             } catch (NullPointerException ex) {
     243            } catch (NullPointerException ex) { // NOPMD
    244244                Main.error(ex); // SAXException does not chain correctly
    245245                throw new SAXException(tr("Null pointer exception, possibly some missing tags."), ex);
  • trunk/src/org/openstreetmap/josm/io/NmeaReader.java

    r11620 r11746  
    415415            return true;
    416416
    417         } catch (RuntimeException ex) {
     417        } catch (IllegalArgumentException | IndexOutOfBoundsException ex) {
    418418            // out of bounds and such
    419419            Main.debug(ex);
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandler.java

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

    r10657 r11746  
    146146                }
    147147            }
    148         } catch (RuntimeException ex) {
     148        } catch (RuntimeException ex) { // NOPMD
    149149            Main.warn("RemoteControl: Error parsing load_and_zoom remote control request:");
    150150            Main.error(ex);
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r11530 r11746  
    725725                        + "Delete from preferences?</html>", plugin.name, plugin.className);
    726726            }
    727         } catch (RuntimeException e) {
     727        } catch (RuntimeException e) { // NOPMD
    728728            pluginLoadingExceptions.put(plugin.name, e);
    729729            Main.error(e);
     
    823823            try {
    824824                task.run();
    825             } catch (RuntimeException e) {
     825            } catch (RuntimeException e) { // NOPMD
    826826                Main.error(e);
    827827                return null;
     
    10011001                    plugins = SubclassFilteredCollection.filter(plugins, pi -> pluginsWantedName.contains(pi.name));
    10021002                }
    1003             } catch (RuntimeException e) {
     1003            } catch (RuntimeException e) { // NOPMD
    10041004                Main.warn(tr("Failed to download plugin information list"));
    10051005                Main.error(e);
     
    10461046                try {
    10471047                    pluginDownloadTask.run();
    1048                 } catch (RuntimeException e) {
     1048                } catch (RuntimeException e) { // NOPMD
    10491049                    Main.error(e);
    10501050                    alertFailedPluginUpdate(parent, pluginsToUpdate);
  • trunk/src/org/openstreetmap/josm/tools/AudioPlayer.java

    r11472 r11746  
    5858         * Called to execute the commands in the other thread
    5959         */
    60         protected void play(URL url, double offset, double speed) throws Exception {
     60        protected void play(URL url, double offset, double speed) throws InterruptedException, IOException {
    6161            this.url = url;
    6262            this.offset = offset;
     
    6767        }
    6868
    69         protected void pause() throws Exception {
     69        protected void pause() throws InterruptedException, IOException {
    7070            command = Command.PAUSE;
    7171            send();
    7272        }
    7373
    74         private void send() throws Exception {
     74        private void send() throws InterruptedException, IOException {
    7575            result = Result.WAITING;
    7676            interrupt();
     
    7979            }
    8080            if (result == Result.FAILED)
    81                 throw exception;
     81                throw new IOException(exception);
    8282        }
    8383
     
    121121     * start at the beginning of the stream
    122122     * @param url The resource to play, which must be a WAV file or stream
    123      * @throws Exception audio fault exception, e.g. can't open stream, unhandleable audio format
    124      */
    125     public static void play(URL url) throws Exception {
     123     * @throws InterruptedException thread interrupted
     124     * @throws IOException audio fault exception, e.g. can't open stream, unhandleable audio format
     125     */
     126    public static void play(URL url) throws InterruptedException, IOException {
    126127        AudioPlayer instance = AudioPlayer.getInstance();
    127128        if (instance != null)
     
    133134     * @param url The resource to play, which must be a WAV file or stream
    134135     * @param seconds The number of seconds into the audio to start playing
    135      * @throws Exception audio fault exception, e.g. can't open stream, unhandleable audio format
    136      */
    137     public static void play(URL url, double seconds) throws Exception {
     136     * @throws InterruptedException thread interrupted
     137     * @throws IOException audio fault exception, e.g. can't open stream, unhandleable audio format
     138     */
     139    public static void play(URL url, double seconds) throws InterruptedException, IOException {
    138140        AudioPlayer instance = AudioPlayer.getInstance();
    139141        if (instance != null)
     
    146148     * @param seconds The number of seconds into the audio to start playing
    147149     * @param speed Rate at which audio playes (1.0 = real time, &gt; 1 is faster)
    148      * @throws Exception audio fault exception, e.g. can't open stream,  unhandleable audio format
    149      */
    150     public static void play(URL url, double seconds, double speed) throws Exception {
     150     * @throws InterruptedException thread interrupted
     151     * @throws IOException audio fault exception, e.g. can't open stream,  unhandleable audio format
     152     */
     153    public static void play(URL url, double seconds, double speed) throws InterruptedException, IOException {
    151154        AudioPlayer instance = AudioPlayer.getInstance();
    152155        if (instance != null)
     
    156159    /**
    157160     * Pauses the currently playing audio stream. Does nothing if nothing playing.
    158      * @throws Exception audio fault exception, e.g. can't open stream,  unhandleable audio format
    159      */
    160     public static void pause() throws Exception {
     161     * @throws InterruptedException thread interrupted
     162     * @throws IOException audio fault exception, e.g. can't open stream,  unhandleable audio format
     163     */
     164    public static void pause() throws InterruptedException, IOException {
    161165        AudioPlayer instance = AudioPlayer.getInstance();
    162166        if (instance != null)
     
    220224            audioPlayer = new AudioPlayer();
    221225            return audioPlayer;
    222         } catch (RuntimeException ex) {
     226        } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException ex) {
    223227            Main.error(ex);
    224228            return null;
     
    233237            try {
    234238                pause();
    235             } catch (Exception e) {
     239            } catch (InterruptedException | IOException e) {
    236240                Main.warn(e);
    237241            }
  • trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java

    r11620 r11746  
    8282                        z == null ? 18 : Integer.parseInt(z));
    8383            }
    84         } catch (NumberFormatException | NullPointerException | ArrayIndexOutOfBoundsException ex) {
     84        } catch (NumberFormatException | ArrayIndexOutOfBoundsException ex) {
    8585            Main.error(ex);
    8686        }
  • trunk/src/org/openstreetmap/josm/tools/WindowGeometry.java

    r11381 r11746  
    194194                       "Cannot restore window geometry from preferences.",
    195195                            preferenceKey, field, v), e);
    196         } catch (RuntimeException e) {
     196        } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    197197            throw new WindowGeometryException(
    198198                    tr("Failed to parse field ''{1}'' in preference with key ''{0}''. Exception was: {2}. " +
  • trunk/src/org/openstreetmap/josm/tools/bugreport/BugReport.java

    r10902 r11746  
    126126            try {
    127127                out.println(ShowStatusReportAction.getReportHeader());
    128             } catch (RuntimeException e) {
     128            } catch (RuntimeException e) { // NOPMD
    129129                out.println("Could not generate status report: " + e.getMessage());
    130130            }
  • trunk/src/org/openstreetmap/josm/tools/bugreport/BugReportDialog.java

    r11196 r11746  
    222222                current = current.getParent();
    223223            }
    224         } catch (RuntimeException e) {
     224        } catch (RuntimeException e) { // NOPMD
    225225            BugReport.intercept(e).put("current", current).warn();
    226226        }
  • trunk/src/org/openstreetmap/josm/tools/bugreport/ReportedException.java

    r11739 r11746  
    6666        try {
    6767            BugReportQueue.getInstance().submit(this);
    68         } catch (RuntimeException e) {
     68        } catch (RuntimeException e) { // NOPMD
    6969            e.printStackTrace();
    7070        }
     
    218218                string = value.toString();
    219219            }
    220         } catch (RuntimeException t) {
     220        } catch (RuntimeException t) { // NOPMD
    221221            Main.warn(t);
    222222            string = "<Error calling toString()>";
Note: See TracChangeset for help on using the changeset viewer.