01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
10: //The Original Code is "The Columba Project"
11: //
12: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14: //
15: //All Rights Reserved.
16: package org.columba.core.command;
17:
18: import java.lang.reflect.InvocationTargetException;
19: import java.lang.reflect.Method;
20:
21: /**
22: * Throwing this exception in a Command aborts the execution immediately.
23: *
24: * @author Timo Stich (tstich@users.sourceforge.net)
25: */
26: public class CommandCancelledException extends Exception {
27: /**
28: * Serialize version uid which was generated from the compiler.
29: */
30: private static final long serialVersionUID = 7444994996504305731L;
31:
32: /**
33: * Constructor for CommandCancelledException.
34: */
35: public CommandCancelledException() {
36: super ();
37: }
38:
39: /**
40: * Constructor for CommandCancelledException.
41: *
42: * @param message
43: */
44: public CommandCancelledException(String message) {
45: super (message);
46: }
47:
48: /**
49: * Constructor for CommandCancelledException.
50: *
51: * @param message
52: * @param cause
53: */
54: public CommandCancelledException(String message, Throwable cause) {
55: this (message);
56: compatibleInitCause(cause);
57: }
58:
59: /**
60: * Constructor for CommandCancelledException.
61: *
62: * @param cause
63: */
64: public CommandCancelledException(Throwable cause) {
65: this ();
66: compatibleInitCause(cause);
67: }
68:
69: private void compatibleInitCause(Throwable cause) {
70: try {
71: Method initCause = getClass().getMethod(
72: "initCause", new Class[] { Throwable.class }); //$NON-NLS-1$
73: initCause.invoke(this , new Object[] { cause });
74: } catch (NoSuchMethodException nsme) {
75: // nothing to do yet
76: } catch (IllegalAccessException iae) {
77: // nothing to do yet
78: } catch (InvocationTargetException ite) {
79: // nothing to do yet
80: }
81: }
82: }
|