Java Tutorial/Apache Common/ExceptionUtils — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 08:18, 1 июня 2010
ExceptionUtils.getThrowableCount
<source lang="java">
import org.apache.rumons.lang.exception.ExceptionUtils; import org.apache.rumons.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); }
}</source>