KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > framework > core > Sync4jException


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 package sync4j.framework.core;
19
20 import java.io.PrintStream JavaDoc;
21 import java.io.PrintWriter JavaDoc;
22
23 import java.text.MessageFormat JavaDoc;
24
25
26 /**
27  * Because this class must be JDK 1.1.8 compliant, we can't use the <i>cause</i>
28  * stuff of the JDK 1.2...
29  *
30  * @author Stefano Fornari @ Funambol
31  *
32  * @version $Id: Sync4jException.java,v 1.3 2005/03/02 20:57:37 harrie Exp $
33  */

34 public class Sync4jException extends Exception JavaDoc {
35    Throwable JavaDoc cause;
36
37    /**
38      * @param strMsg human readable String that describes the cause of the
39      * exception
40      */

41     public Sync4jException(final String JavaDoc strMsg) {
42         super(strMsg);
43     }
44
45     /**
46      * Constructor for the ServerException object
47      *
48      * @param strMsg Description of the Parameter
49      * @param aobjArgs Description of the Parameter
50      */

51     public Sync4jException(final String JavaDoc strMsg, final Object JavaDoc[] aobjArgs) {
52          super(MessageFormat.format(strMsg, aobjArgs));
53     }
54
55     public Sync4jException(final String JavaDoc strMsg, final Throwable JavaDoc cause) {
56         super(strMsg);
57
58         this.cause = cause;
59     }
60
61     public Sync4jException(final Throwable JavaDoc cause) {
62         this("", cause);
63     }
64
65     public Throwable JavaDoc getCause() {
66         return cause;
67     }
68
69     public void printStackTrace() {
70         super.printStackTrace();
71         if (cause != null) {
72             System.err.println("Caused by:");
73             cause.printStackTrace();
74         }
75     }
76
77     public void printStackTrace(PrintStream JavaDoc ps) {
78         super.printStackTrace(ps);
79         if (cause != null) {
80             System.err.println("Caused by:");
81             cause.printStackTrace(ps);
82         }
83     }
84
85     public void printStackTrace(PrintWriter JavaDoc pw) {
86         super.printStackTrace(pw);
87         if (cause != null) {
88             System.err.println("Caused by:");
89             cause.printStackTrace(pw);
90         }
91     }
92 }
Popular Tags