Author: ivaynberg Date: Fri Nov 19 21:52:12 2010 New Revision: 1037044 URL: http://svn.apache.org/viewvc?rev=1037044&view=rev Log: javadoc
Modified: wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/lang/Exceptions.java Modified: wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/lang/Exceptions.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/lang/Exceptions.java?rev=1037044&r1=1037043&r2=1037044&view=diff ============================================================================== --- wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/lang/Exceptions.java (original) +++ wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/lang/Exceptions.java Fri Nov 19 21:52:12 2010 @@ -27,11 +27,28 @@ public class Exceptions } /** + * Gets root cause of the throwable + * + * @param throwable + * @return root cause + */ + public Throwable getRootCause(Throwable throwable) + { + Throwable cursor = throwable; + while (cursor.getCause() != null) + { + cursor = cursor.getCause(); + } + return cursor; + } + + /** + * Looks for a cause of the specified type in throwable's chain * * @param <T> * @param throwable * @param causeType - * @return + * @return matched {...@link Throwable} in the chain or {...@code null} if none */ public static <T extends Throwable> T findCause(Throwable throwable, final Class<T> causeType) { @@ -81,20 +98,28 @@ public class Exceptions } /** + * Visitor used to visit {...@link Throwable} chains * * @param <T> */ public static interface IThrowableVisitor<T> { + /** + * Visit a throwable + * + * @param throwable + * @param visit + */ void visit(Throwable throwable, Visit<T> visit); } /** + * Visits the {...@link Throwable}'s chain * * @param <T> * @param throwable * @param visitor - * @return + * @return result set on visitor or {...@code null} if none */ public static <T> T visit(Throwable throwable, IThrowableVisitor<T> visitor) {