You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2018/05/29 21:41:27 UTC
commons-release-plugin git commit: Better error reporting and
bullet-proofing.
Repository: commons-release-plugin
Updated Branches:
refs/heads/master 25e3dc12e -> 0c29ac3a1
Better error reporting and bullet-proofing.
Project: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/commit/0c29ac3a
Tree: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/tree/0c29ac3a
Diff: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/diff/0c29ac3a
Branch: refs/heads/master
Commit: 0c29ac3a1f030db55fbc78796516251f9c9c608c
Parents: 25e3dc1
Author: Gary Gregory <ga...@gmail.com>
Authored: Tue May 29 15:41:24 2018 -0600
Committer: Gary Gregory <ga...@gmail.com>
Committed: Tue May 29 15:41:24 2018 -0600
----------------------------------------------------------------------
.../commons/release/plugin/SharedFunctions.java | 23 +++++++++++---------
1 file changed, 13 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/0c29ac3a/src/main/java/org/apache/commons/release/plugin/SharedFunctions.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/release/plugin/SharedFunctions.java b/src/main/java/org/apache/commons/release/plugin/SharedFunctions.java
index 1980819..71898b0 100755
--- a/src/main/java/org/apache/commons/release/plugin/SharedFunctions.java
+++ b/src/main/java/org/apache/commons/release/plugin/SharedFunctions.java
@@ -48,18 +48,20 @@ public final class SharedFunctions {
* Cleans and then initializes an empty directory that is given by the <code>workingDirectory</code>
* parameter.
*
- * @param log is the maven log for output logging, particularly in regards to error management.
+ * @param log is the Maven log for output logging, particularly in regards to error management.
* @param workingDirectory is a {@link File} that represents the directory to first attempt to delete then create.
- * @throws MojoExecutionException when an {@link IOException} occurrs for the purpose of bubbling the exception
- * up to maven properly.
+ * @throws MojoExecutionException when an {@link IOException} or {@link NullPointerException} is caught for the
+ * purpose of bubbling the exception up to Maven properly.
*/
public static void initDirectory(Log log, File workingDirectory) throws MojoExecutionException {
if (workingDirectory.exists()) {
try {
FileUtils.deleteDirectory(workingDirectory);
- } catch (IOException e) {
- log.error(e.getMessage());
- throw new MojoExecutionException("Unable to remove directory: " + e.getMessage(), e);
+ } catch (IOException | NullPointerException e) {
+ final String message = String.format("Unable to remove directory %s: %s", workingDirectory,
+ e.getMessage());
+ log.error(message);
+ throw new MojoExecutionException(message, e);
}
}
if (!workingDirectory.exists()) {
@@ -74,14 +76,15 @@ public final class SharedFunctions {
* @param log the {@link Log}, the maven logger.
* @param fromFile the {@link File} from which to copy.
* @param toFile the {@link File} to which to copy into.
- * @throws MojoExecutionException if an {@link IOException} occurs.
+ * @throws MojoExecutionException if an {@link IOException} or {@link NullPointerException} is caught.
*/
public static void copyFile(Log log, File fromFile, File toFile) throws MojoExecutionException {
try {
FileUtils.copyFile(fromFile, toFile);
- } catch (IOException e) {
- log.error(e.getMessage());
- throw new MojoExecutionException("Unable to copy file: " + e.getMessage(), e);
+ } catch (IOException | NullPointerException e) {
+ final String message = String.format("Unable to copy file %s tp %s: %s", fromFile, toFile, e.getMessage());
+ log.error(message);
+ throw new MojoExecutionException(message, e);
}
}
}