ExceptionUtils.getThrowableCount : ExceptionUtils « Apache Common « Java Tutorial






import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.commons.lang.exception.NestableException;

public class MainClass {
    public static void main(String[] args) {
        try {
            a();
        } catch (Exception e) {
            System.out.println(
                "Number of Throwable objects in the exception chain is: " +
                ExceptionUtils.getThrowableCount(e));
            e.printStackTrace();
        }
    }

    public static void a() throws Exception {
        try {
            b();
        } catch (Exception e) {
            throw new ApplicationException("Packaged into Nestable", e);
        }
    }

    public static void b() throws Exception {
        throw new Exception("The Root Exception");
    }
}
class ApplicationException extends NestableException {
    public ApplicationException(String msg, Throwable cause) {
        super(msg, cause);
    }
}
  Download:  CommonLangExceptionUtils.getThrowableCount.zip( 200 k)








37.13.ExceptionUtils
37.13.1.ExceptionUtils.getThrowableCount