diff options
author | Stefan Bodewig <bodewig@apache.org> | 2016-12-22 07:11:09 +0100 |
---|---|---|
committer | Stefan Bodewig <bodewig@apache.org> | 2016-12-22 07:11:09 +0100 |
commit | 0715dda3176e34dd0140043e209e66c469c49ece (patch) | |
tree | 7924d3140c7e29f30b4ee2cf42757b77f4477036 /src | |
parent | 934adc2ee778bd12f9226b6b287dd34294708361 (diff) | |
download | ant-0715dda3176e34dd0140043e209e66c469c49ece.tar.gz |
use better suited exceptions
Diffstat (limited to 'src')
9 files changed, 17 insertions, 17 deletions
diff --git a/src/main/org/apache/tools/ant/Main.java b/src/main/org/apache/tools/ant/Main.java index 4626e14d7..b104fd33a 100644 --- a/src/main/org/apache/tools/ant/Main.java +++ b/src/main/org/apache/tools/ant/Main.java @@ -978,10 +978,6 @@ public class Main implements AntMain { project.setInputHandler(handler); } - // TODO: (Jon Skeet) Any reason for writing a message and then using a bare - // RuntimeException rather than just using a BuildException here? Is it - // in case the message could end up being written to no loggers (as the - // loggers could have failed to be created due to this failure)? /** * Creates the default build logger for sending build events to the ant * log. @@ -1003,7 +999,7 @@ public class Main implements AntMain { System.err.println("The specified logger class " + loggerClassname + " could not be used because " + e.getMessage()); - throw new RuntimeException(); + throw e; } } else { logger = new DefaultLogger(); diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java index f7d3a3608..34dddb26f 100644 --- a/src/main/org/apache/tools/ant/Project.java +++ b/src/main/org/apache/tools/ant/Project.java @@ -1836,7 +1836,7 @@ public class Project implements ResourceFactory { if (st == null) { tsort(root[i], targetTable, state, visiting, ret); } else if (st == VISITING) { - throw new RuntimeException("Unexpected node in visiting state: " + throw new BuildException("Unexpected node in visiting state: " + root[i]); } } @@ -1855,7 +1855,7 @@ public class Project implements ResourceFactory { if (st == null) { tsort(curTarget, targetTable, state, visiting, complete); } else if (st == VISITING) { - throw new RuntimeException("Unexpected node in visiting state: " + throw new BuildException("Unexpected node in visiting state: " + curTarget); } } @@ -1941,7 +1941,7 @@ public class Project implements ResourceFactory { } final String p = visiting.pop(); if (root != p) { - throw new RuntimeException("Unexpected internal error: expected to " + throw new BuildException("Unexpected internal error: expected to " + "pop " + root + " but got " + p); } state.put(root, VISITED); diff --git a/src/main/org/apache/tools/ant/ProjectHelperRepository.java b/src/main/org/apache/tools/ant/ProjectHelperRepository.java index 02ad62d85..7fe92c491 100644 --- a/src/main/org/apache/tools/ant/ProjectHelperRepository.java +++ b/src/main/org/apache/tools/ant/ProjectHelperRepository.java @@ -62,7 +62,7 @@ public class ProjectHelperRepository { PROJECTHELPER2_CONSTRUCTOR = ProjectHelper2.class.getConstructor(); } catch (Exception e) { // ProjectHelper2 must be available - throw new RuntimeException(e); + throw new BuildException(e); } } @@ -263,7 +263,7 @@ public class ProjectHelperRepository { return helper; } } - throw new RuntimeException("BUG: at least the ProjectHelper2 should " + throw new BuildException("BUG: at least the ProjectHelper2 should " + "have supported the file " + buildFile); } @@ -286,7 +286,7 @@ public class ProjectHelperRepository { return helper; } } - throw new RuntimeException("BUG: at least the ProjectHelper2 should " + throw new BuildException("BUG: at least the ProjectHelper2 should " + "have supported the file " + antlib); } diff --git a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java index 24b5bb62a..8fce71eeb 100644 --- a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java +++ b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java @@ -721,7 +721,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { * @return the requested class. * @exception Exception if the class could not be loaded. */ - private Class loadClass(final String classname) throws Exception { + private Class loadClass(final String classname) throws ClassNotFoundException { setupLoader(); if (loader == null) { return Class.forName(classname); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java b/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java index a6cd6d652..605aba969 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java @@ -322,7 +322,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware * @see #addParam(java.lang.String, java.lang.String) * @see #setOutputProperty(java.lang.String, java.lang.String) */ - private void createTransformer() throws Exception { + private void createTransformer() + throws IOException, ParserConfigurationException, SAXException, TransformerException { if (templates == null) { readTemplates(); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/JarFileIterator.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/JarFileIterator.java index bc315d2e2..c468b952a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/depend/JarFileIterator.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/JarFileIterator.java @@ -22,6 +22,8 @@ import java.io.InputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; +import org.apache.tools.ant.BuildException; + /** * A class file iterator which iterates through the contents of a Java jar * file. @@ -79,7 +81,7 @@ public class JarFileIterator implements ClassFileIterator { text += ": " + message; } - throw new RuntimeException("Problem reading JAR file: " + text); + throw new BuildException("Problem reading JAR file: " + text); } return nextElement; diff --git a/src/main/org/apache/tools/ant/util/depend/AbstractAnalyzer.java b/src/main/org/apache/tools/ant/util/depend/AbstractAnalyzer.java index 5c95d75b8..a312ff4b5 100644 --- a/src/main/org/apache/tools/ant/util/depend/AbstractAnalyzer.java +++ b/src/main/org/apache/tools/ant/util/depend/AbstractAnalyzer.java @@ -22,6 +22,7 @@ import java.util.Enumeration; import java.util.Vector; import java.util.zip.ZipFile; +import org.apache.tools.ant.BuildException; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.util.VectorSet; @@ -80,7 +81,7 @@ public abstract class AbstractAnalyzer implements DependencyAnalyzer { */ public Enumeration<File> getFileDependencies() { if (!supportsFileDependencies()) { - throw new RuntimeException("File dependencies are not supported " + throw new BuildException("File dependencies are not supported " + "by this analyzer"); } if (!determined) { diff --git a/src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java b/src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java index a24537ac8..7a5cfa4d3 100644 --- a/src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java +++ b/src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java @@ -126,7 +126,7 @@ public class JavaxScriptRunner extends ScriptRunnerBase { } } - private ReflectWrapper createEngine() throws Exception { + private ReflectWrapper createEngine() { if (engine != null) { return engine; } diff --git a/src/main/org/apache/tools/tar/TarInputStream.java b/src/main/org/apache/tools/tar/TarInputStream.java index 964e5c5f5..82c0a0d45 100644 --- a/src/main/org/apache/tools/tar/TarInputStream.java +++ b/src/main/org/apache/tools/tar/TarInputStream.java @@ -276,7 +276,7 @@ public class TarInputStream extends FilterInputStream { while (numToSkip > 0) { long skipped = skip(numToSkip); if (skipped <= 0) { - throw new RuntimeException("failed to skip current tar" + throw new IOException("failed to skip current tar" + " entry"); } numToSkip -= skipped; |