KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > syncclient > spdm > DMException


1 /**
2  * Copyright (C) 2003-2005 Funambol
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package sync4j.syncclient.spdm;
20
21 import java.io.PrintStream JavaDoc;
22 import java.io.PrintWriter JavaDoc;
23
24 /**
25  * This class represents a device manager error. It keeps track of the causing
26  * exception, if any.
27  *
28  * @author Fabio Maggi @ Funambol
29  * @version $Id: DMException.java,v 1.2 2005/01/19 11:18:36 fabius Exp $
30  */

31 public class DMException extends Exception JavaDoc {
32
33     private Throwable JavaDoc cause = null;
34
35     /**
36      * Creates a new instance of <code>UpdateException</code> without detail message.
37      */

38     public DMException() {
39     }
40
41
42     /**
43      * Constructs an instance of <code>DMException</code> with the specified detail message.
44      * @param msg the detail message.
45      */

46     public DMException(final String JavaDoc msg) {
47         super(msg);
48     }
49
50     /**
51      * Constructs an instance of <code>DMException</code> with the specified detail message
52      * and root cause.
53      *
54      * @param msg the detail message.
55      * @param cause the root cause
56      */

57     public DMException(final String JavaDoc msg, final Throwable JavaDoc cause) {
58         this(msg);
59         this.cause = cause;
60     }
61
62     /**
63      * Returns the root cause of this exception
64      *
65      * @return the cause of this exception if any, or null otherwise
66      */

67     public Throwable JavaDoc getCause() {
68         return cause;
69     }
70
71     /**
72      * Prints the exception and its cause (if any) stack trace
73      */

74     public void printStackTrace() {
75         super.printStackTrace();
76         if (cause != null) {
77             System.err.println("Caused by:");
78             cause.printStackTrace();
79         }
80     }
81 }
Popular Tags