get Deepest Throwable - Java java.lang

Java examples for java.lang:Throwable

Description

get Deepest Throwable

Demo Code


//package com.java2s;

public class Main {
    public static Throwable getDeepestThrowable(Throwable t) {
        Throwable parent = t;//from   w w  w.  j a  v a2 s .c o  m
        Throwable child = t.getCause();
        while (null != child) {
            parent = child;
            child = parent.getCause();
        }

        return parent;

    }
}

Related Tutorials