1 /*
2 * Copyright (c) 2001 - 2005 ivata limited.
3 * All rights reserved.
4 * -----------------------------------------------------------------------------
5 * ivata masks may be redistributed under the GNU General Public
6 * License as published by the Free Software Foundation;
7 * version 2 of the License.
8 *
9 * These programs are free software; you can redistribute them and/or
10 * modify them under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; version 2 of the License.
12 *
13 * These programs are distributed in the hope that they will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 *
17 * See the GNU General Public License in the file LICENSE.txt for more
18 * details.
19 *
20 * If you would like a copy of the GNU General Public License write to
21 *
22 * Free Software Foundation, Inc.
23 * 59 Temple Place - Suite 330
24 * Boston, MA 02111-1307, USA.
25 *
26 *
27 * To arrange commercial support and licensing, contact ivata at
28 * http://www.ivata.com/contact.jsp
29 * -----------------------------------------------------------------------------
30 * $Log: SystemException.java,v $
31 * Revision 1.3 2005/04/09 18:04:17 colinmacleod
32 * Changed copyright text to GPL v2 explicitly.
33 *
34 * Revision 1.2 2005/03/10 10:27:20 colinmacleod
35 * Fixed initialization of cause in super constructor.
36 *
37 * Revision 1.1 2005/01/19 12:41:33 colinmacleod
38 * Renamed to SystemException.
39 *
40 * Revision 1.2 2005/01/06 22:21:45 colinmacleod
41 * Moved up a version number.
42 * Changed copyright notices to 2005.
43 * Updated the documentation:
44 * - started working on multiproject:site docu.
45 * - changed the logo.
46 * Added checkstyle and fixed LOADS of style issues.
47 * Added separate thirdparty subproject.
48 * Added struts (in web), util and webgui (in webtheme) from ivata op.
49 *
50 * Revision 1.6 2004/11/12 15:52:17 colinmacleod
51 * Added constructor which just has a message.
52 *
53 * Revision 1.5 2004/07/13 19:48:11 colinmacleod
54 * Moved project to POJOs from EJBs.
55 * Applied PicoContainer to services layer (replacing session EJBs).
56 * Applied Hibernate to persistence layer (replacing entity EJBs).
57 *
58 * Revision 1.4 2004/03/21 21:16:36 colinmacleod
59 * Shortened name to ivata op.
60 *
61 * Revision 1.3 2004/02/01 22:07:32 colinmacleod
62 * Added full names to author tags
63 *
64 * Revision 1.2 2004/01/29 14:34:15 janboros
65 * fixing package declaration
66 *
67 * Revision 1.1.1.1 2004/01/27 20:59:46 colinmacleod
68 * Moved ivata op to SourceForge.
69 *
70 * Revision 1.3 2003/10/16 15:35:48 jano
71 * Fixes problems with building and some problems with splitting to subprojects
72 *
73 * Revision 1.2 2003/10/15 14:13:53 colin
74 * fixing for XDoclet
75 *
76 * Revision 1.1 2003/01/21 08:59:37 colin
77 * first version of re-structured intranet struts
78 * -----------------------------------------------------------------------------
79 */
80 package com.ivata.mask.util;
81
82 import java.io.Serializable;
83
84 /***
85 * <p>
86 * This error message encapsulates another message which caused it.
87 * </p>
88 *
89 * @since ivata masks 0.4 (2003-01-10)
90 * @author Colin MacLeod
91 * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
92 * @version $Revision: 1.3 $
93 */
94 public class SystemException extends Exception implements Serializable {
95 /***
96 * <p>
97 * Get a composite message for the given message and cause.
98 * </p>
99 *
100 * @param message
101 * clear message indicating what caused the exception to happen
102 * and what should be done to resolve it.
103 * @param cause
104 * the <code>Throwable</code> which caused this exception to
105 * happen.
106 * @return Combined message detailing the original message and cause.
107 */
108 private static String getMessage(final String message,
109 final Throwable cause) {
110 StringBuffer buffer = new StringBuffer();
111 if (message != null) {
112 buffer.append(message);
113 } else {
114 buffer.append("SystemException");
115 }
116 if (cause != null) {
117 buffer.append(": caused by ");
118 buffer.append(cause.getClass().toString());
119 }
120 if ((cause != null) && (cause.getMessage() != null)) {
121 buffer.append(", original message: ");
122 buffer.append(cause.getMessage());
123 }
124 return buffer.toString();
125 }
126 /***
127 * <p>
128 * Create a <code>SystemException</code> with a message.
129 * </p>
130 *
131 * @param message
132 * clear message indicating what caused the exception to happen
133 * and what should be done to resolve it.
134 */
135 public SystemException(final String message) {
136 this(message, null);
137 }
138 /***
139 * <p>
140 * Create a <code>SystemException</code> with the given message and
141 * cause.
142 * </p>
143 *
144 * @param message
145 * clear message indicating what caused the exception to happen
146 * and what should be done to resolve it.
147 * @param cause
148 * the <code>Throwable</code> which caused this exception to
149 * happen.
150 */
151 public SystemException(final String message, final Throwable cause) {
152 super(getMessage(message, cause), cause);
153 }
154 /***
155 * <p>
156 * Create a <code>SystemException</code> with the given cause.
157 * </p>
158 *
159 * @param cause
160 * the <code>Throwable</code> which caused this exception to
161 * happen.
162 */
163 public SystemException(final Throwable cause) {
164 this(null, cause);
165 }
166 }