请问:
1,Throwable的子类如何在构造器中接受一个cause对象作为参数来创建异常链
2,异常中 initCause方法怎么理解 它怎样和其他的异常链连接起来 
希望能举个例子
谢谢

解决方案 »

  1.   

    Throwable的子类中添加一个 构造方法,
    public class A extends Throwable{
         public A(Cause cause){
              //...........
         }
    }
      

  2.   

    public class YourException extends Throwable
    {
    /**
     * 
     */
    private static final long serialVersionUID = 6553677709090L;

    public YourException()
    {
    super();
    } public YourException(String message)
    {
    super(message);
    } public YourException(Throwable cause)
    {
    super(cause);
    }

    public YourException(String message, Throwable cause)
    {
    super(message, cause);
    }
    }
    public class YourBussinessClass......
    {
    public void method(LoaderTaskInformation taskInfo) throws YourException 
    {
    logger.info("............");
    ..........
    try
    {
    xxx//would throw xxxExcetpion

    catch (xxxExcetpion e)
    {
    //logger.error(e);
    throw new YourException(e);
    }
    }