Throwable root Cause - Java java.lang

Java examples for java.lang:Throwable

Description

Throwable root Cause

Demo Code


//package com.java2s;

public class Main {

    public static Throwable getRootCause(Throwable ex) {
        Throwable rootCause = null;
        Throwable cause = ex.getCause();
        while (cause != null && cause != rootCause) {
            rootCause = cause;// ww  w .j  a v  a2 s  . c o  m
            cause = cause.getCause();
        }
        return rootCause;
    }
}

Related Tutorials