View Javadoc

1   /******************************************************************
2   JADE - Java Agent DEvelopment Framework is a framework to develop 
3   multi-agent systems in compliance with the FIPA specifications.
4   Copyright (C) 2000 CSELT S.p.A. 
5   
6   GNU Lesser General Public License
7   
8   This library is free software; you can redistribute it and/or
9   modify it under the terms of the GNU Lesser General Public
10  License as published by the Free Software Foundation, 
11  version 2.1 of the License. 
12  
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  Lesser General Public License for more details.
17  
18  You should have received a copy of the GNU Lesser General Public
19  License along with this library; if not, write to the
20  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA  02111-1307, USA.
22  *****************************************************************/
23  
24  package JADE_SL.onto;
25  
26  /***
27  
28    This class acts as a base class for all the exceptions that wrap
29    another (nested) exception. The typical usage for descendents of
30    this class is to throw them within the <code>catch</code> block for
31    their nested exception.
32  
33    @author Giovanni Rimassa - Universita` di Parma
34    @version $Date: 2003/10/09 13:00:36 $ $Revision: 1.1.1.1 $
35  
36   */
37  public abstract class WrapperException extends Exception {
38    private Throwable nested = null;
39  
40    protected WrapperException(String m, Throwable t) {
41    	super(m);
42      nested = t;
43    }
44  
45    protected WrapperException(String m) {
46    	super(m);
47    }
48  
49    public String getMessage() {
50      if((nested != null)) {
51        return super.getMessage()+" [nested message is: "+nested.getMessage()+"]";
52      }
53      return super.getMessage();
54    }
55  
56    public void printStackTrace() {
57      super.printStackTrace();
58      if(nested != null) {
59        System.err.println("Nested Exception is:");
60        nested.printStackTrace();
61      }
62    }
63  
64    /***
65       Reads the exception wrapped by this object.
66       @return the <code>Throwable</code> object that is the exception 
67       that was originally thrown
68    */
69    public Throwable getNested() {
70      return nested;
71    }
72  
73  }