Ignore:
Timestamp:
2016-05-15T00:51:10+02:00 (9 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/tools
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • 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.