This is an automated email from the ASF dual-hosted git repository.

mbenson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git

commit 71f44247d449f7f3fa2928e8de76e3107f6497f5
Author: Matt Benson <[email protected]>
AuthorDate: Wed Feb 9 19:05:33 2022 -0600

    add static BuildException factory method
---
 src/main/org/apache/tools/ant/BuildException.java | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/main/org/apache/tools/ant/BuildException.java 
b/src/main/org/apache/tools/ant/BuildException.java
index 6dc2c12..996043a 100644
--- a/src/main/org/apache/tools/ant/BuildException.java
+++ b/src/main/org/apache/tools/ant/BuildException.java
@@ -24,6 +24,18 @@ public class BuildException extends RuntimeException {
 
     private static final long serialVersionUID = -5419014565354664240L;
 
+    /**
+     * Get a {@link BuildException} for the specified {@link Throwable}.
+     * @param t
+     * @return {@link BuildException}
+     */
+    public static BuildException of(Throwable t) {
+        if (t instanceof BuildException) {
+            return (BuildException) t;
+        }
+        return new BuildException(t);
+    }
+
     /** Location in the build file where the exception occurred */
     private Location location = Location.UNKNOWN_LOCATION;
 

Reply via email to