All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.rgi.common.util.ThrowableUtility Maven / Gradle / Ivy

The newest version!
package com.rgi.common.util;

/**
 * Utilities for {@link Throwable} objects
 *
 * @author Luke Lambert
 *
 */
public class ThrowableUtility
{
    /**
     * Calls {@link Throwable#getCause()} recursively and to return the root
     * cause of a {@link Throwable}, or null if the input was null
     *
     * @param th
     *             {@link Throwable} object
     * @return the root cause of a {@link Throwable}, or null if the input was
     *             null
     */
    public static Throwable getRoot(final Throwable th)
    {
        Throwable root = th;

        while(root != null && root.getCause() != null)
        {
            root = root.getCause();
        }

        return root;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy