Changeset 13207 in josm


Ignore:
Timestamp:
2017-12-17T01:25:46+01:00 (5 weeks ago)
Author:
Don-vip
Message:

enable PMD rule PreserveStackTrace + add missing jars to run new PMD rule designer

Location:
trunk
Files:
7 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapRendererFactory.java

    r12846 r13207  
    66import java.awt.Graphics2D;
    77import java.lang.reflect.Constructor;
    8 import java.lang.reflect.InvocationTargetException;
    98import java.text.MessageFormat;
    109import java.util.ArrayList;
     
    307306            Constructor<?> c = activeRenderer.getConstructor(Graphics2D.class, NavigatableComponent.class, boolean.class);
    308307            return AbstractMapRenderer.class.cast(c.newInstance(g, viewport, isInactiveMode));
    309         } catch (InvocationTargetException e) {
    310             Logging.debug(e);
    311             throw new MapRendererFactoryException(e.getCause());
    312308        } catch (ReflectiveOperationException | IllegalArgumentException e) {
    313309            throw new MapRendererFactoryException(e);
  • trunk/src/org/openstreetmap/josm/data/projection/ProjectionCLI.java

    r12892 r13207  
    196196            return Double.parseDouble(s);
    197197        } catch (NumberFormatException nfe) {
    198             throw new IllegalArgumentException(tr("Unable to parse number ''{0}''", s));
     198            throw new IllegalArgumentException(tr("Unable to parse number ''{0}''", s), nfe);
    199199        }
    200200    }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/RenderingCLI.java

    r13204 r13207  
    231231                } catch (NumberFormatException nfe) {
    232232                    throw new IllegalArgumentException(
    233                             tr("Expected integer number for option {0}, but got ''{1}''", "--zoom", getopt.getOptarg()));
     233                            tr("Expected integer number for option {0}, but got ''{1}''", "--zoom", getopt.getOptarg()), nfe);
    234234                }
    235235                if (argZoom < 0)
     
    242242                        argBounds = new Bounds(getopt.getOptarg(), ",", Bounds.ParseMethod.LEFT_BOTTOM_RIGHT_TOP, false);
    243243                    } catch (IllegalArgumentException iae) { // NOPMD
    244                         throw new IllegalArgumentException(tr("Unable to parse {0} parameter: {1}", "--bounds", iae.getMessage()));
     244                        throw new IllegalArgumentException(tr("Unable to parse {0} parameter: {1}", "--bounds", iae.getMessage()), iae);
    245245                    }
    246246                }
     
    268268                    } catch (NumberFormatException nfe) {
    269269                        throw new IllegalArgumentException(
    270                                 tr("Expected floating point number for option {0}, but got ''{1}''", "--scale", getopt.getOptarg()));
     270                                tr("Expected floating point number for option {0}, but got ''{1}''", "--scale", getopt.getOptarg()), nfe);
    271271                    }
    272272                    break;
     
    282282                        argAnchor = new LatLon(lat, lon);
    283283                    } catch (IllegalArgumentException iae) { // NOPMD
    284                         throw new IllegalArgumentException(tr("In option {0}: {1}", "--anchor", iae.getMessage()));
     284                        throw new IllegalArgumentException(tr("In option {0}: {1}", "--anchor", iae.getMessage()), iae);
    285285                    }
    286286                    break;
     
    290290                    } catch (NumberFormatException nfe) {
    291291                        throw new IllegalArgumentException(
    292                                 tr("Expected floating point number for option {0}, but got ''{1}''", "--width-m", getopt.getOptarg()));
     292                                tr("Expected floating point number for option {0}, but got ''{1}''", "--width-m", getopt.getOptarg()), nfe);
    293293                    }
    294294                    if (argWidthM <= 0) throw new IllegalArgumentException(
     
    300300                    } catch (NumberFormatException nfe) {
    301301                        throw new IllegalArgumentException(
    302                                 tr("Expected floating point number for option {0}, but got ''{1}''", "--height-m", getopt.getOptarg()));
     302                                tr("Expected floating point number for option {0}, but got ''{1}''", "--height-m", getopt.getOptarg()), nfe);
    303303                    }
    304304                    if (argHeightM <= 0) throw new IllegalArgumentException(
     
    310310                    } catch (NumberFormatException nfe) {
    311311                        throw new IllegalArgumentException(
    312                                 tr("Expected integer number for option {0}, but got ''{1}''", "--width-px", getopt.getOptarg()));
     312                                tr("Expected integer number for option {0}, but got ''{1}''", "--width-px", getopt.getOptarg()), nfe);
    313313                    }
    314314                    if (argWidthPx <= 0) throw new IllegalArgumentException(
     
    320320                    } catch (NumberFormatException nfe) {
    321321                        throw new IllegalArgumentException(
    322                                 tr("Expected integer number for option {0}, but got ''{1}''", "--height-px", getopt.getOptarg()));
     322                                tr("Expected integer number for option {0}, but got ''{1}''", "--height-px", getopt.getOptarg()), nfe);
    323323                    }
    324324                    if (argHeightPx <= 0) throw new IllegalArgumentException(
     
    333333                    } catch (NumberFormatException nfe) {
    334334                        throw new IllegalArgumentException(
    335                                 tr("Expected integer number for option {0}, but got ''{1}''", "--max-image-size", getopt.getOptarg()));
     335                                tr("Expected integer number for option {0}, but got ''{1}''", "--max-image-size", getopt.getOptarg()), nfe);
    336336                    }
    337337                    if (argMaxImageSize < 0) throw new IllegalArgumentException(
     
    551551            return OsmReader.parseDataSet(Files.newInputStream(Paths.get(argInput)), null);
    552552        } catch (IllegalDataException e) {
    553             throw new IllegalDataException(tr("In .osm data file ''{0}'' - ", argInput) + e.getMessage());
     553            throw new IllegalDataException(tr("In .osm data file ''{0}'' - ", argInput) + e.getMessage(), e);
    554554        }
    555555    }
  • trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java

    r12620 r13207  
    328328                throw new OsmOAuthAuthorizationException(tr("Failed to authenticate user ''{0}'' with password ''***'' as OAuth user",
    329329                        userName));
    330         } catch (OsmOAuthAuthorizationException e) {
    331             Logging.debug(e);
    332             throw new OsmLoginFailedException(e.getCause());
    333         } catch (IOException e) {
     330        } catch (OsmOAuthAuthorizationException | IOException e) {
    334331            throw new OsmLoginFailedException(e);
    335332        } finally {
  • trunk/src/org/openstreetmap/josm/io/ChangesetClosedException.java

    r12620 r13207  
    9898
    9999    /**
    100      * Creates the exception with the given error header and the given
    101      * source.
     100     * Creates the exception with the given error header and source.
    102101     *
    103102     * @param errorHeader the error header
     
    105104     */
    106105    public ChangesetClosedException(String errorHeader, Source source) {
    107         super(errorHeader);
     106        this(errorHeader, source, null);
     107    }
     108
     109    /**
     110     * Creates the exception with the given error header, source and cause.
     111     *
     112     * @param errorHeader the error header
     113     * @param source the source for the exception
     114     * @param cause  The cause (which is saved for later retrieval by the {@link #getCause} method).
     115     *               A null value is permitted, and indicates that the cause is nonexistent or unknown.
     116     * @since 13207
     117     */
     118    public ChangesetClosedException(String errorHeader, Source source, Throwable cause) {
     119        super(errorHeader, cause);
    108120        parseErrorHeader(errorHeader);
    109121        this.source = source == null ? Source.UNSPECIFIED : source;
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r12992 r13207  
    487487            String errorHeader = e.getErrorHeader();
    488488            if (e.getResponseCode() == HttpURLConnection.HTTP_CONFLICT && ChangesetClosedException.errorHeaderMatchesPattern(errorHeader))
    489                 throw new ChangesetClosedException(errorHeader, ChangesetClosedException.Source.UPDATE_CHANGESET);
     489                throw new ChangesetClosedException(errorHeader, ChangesetClosedException.Source.UPDATE_CHANGESET, e);
    490490            throw e;
    491491        } finally {
  • trunk/tools/pmd/josm-ruleset.xml

    r13206 r13207  
    3030    <exclude name="UnusedFormalParameter"/>
    3131    <exclude name="UseVarargs"/>
     32  </rule>
     33  <rule ref="category/java/bestpractices.xml/PreserveStackTrace">
     34    <properties>
     35        <property name="violationSuppressXPath" value="//PrimaryExpression/PrimaryPrefix/Name[@Image='BugReport.intercept']"/>
     36    </properties>
    3237  </rule>
    3338  <rule ref="category/java/bestpractices.xml/UnusedFormalParameter">
Note: See TracChangeset for help on using the changeset viewer.