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

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

commit d53bfacede553e14109df9e3ef634085f3ce82d9
Author: Michael Blow <[email protected]>
AuthorDate: Tue Sep 29 10:25:03 2020 -0400

    [NO ISSUE][*DB] += exception helper method
    
    Change-Id: I7d7aee2fb2bb25a59d2825761b127f969348666b
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/8163
    Reviewed-by: Murtadha Hubail <[email protected]>
    Integration-Tests: Jenkins <[email protected]>
    Tested-by: Jenkins <[email protected]>
---
 .../apache/asterix/common/exceptions/ExceptionUtils.java  | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git 
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ExceptionUtils.java
 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ExceptionUtils.java
index 359054e..1f42771 100644
--- 
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ExceptionUtils.java
+++ 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ExceptionUtils.java
@@ -21,6 +21,7 @@ package org.apache.asterix.common.exceptions;
 import java.util.function.Predicate;
 
 import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.IFormattedException;
 
 public class ExceptionUtils {
     public static final String INCORRECT_PARAMETER = "Incorrect parameter.\n";
@@ -85,4 +86,18 @@ public class ExceptionUtils {
         }
         return test.test(e);
     }
+
+    /**
+     * Unwraps enclosed exceptions until a non-product exception is found, 
otherwise returns the root production
+     * exception
+     */
+    public static Throwable unwrap(Throwable e) {
+        Throwable current = e;
+        Throwable cause = e.getCause();
+        while (cause != null && cause != current && current instanceof 
IFormattedException) {
+            current = cause;
+            cause = current.getCause();
+        }
+        return current;
+    }
 }

Reply via email to