1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package nl.toolforge.karma.core.cmd.event;
20
21 import nl.toolforge.karma.core.cmd.Command;
22
23 /***
24 * Generated when an exception is thrown during command execution that should be sent to listeners.
25 *
26 * @author D.A. Smedes
27 * @version $Id: ExceptionEvent.java,v 1.3 2004/11/02 23:57:06 asmedes Exp $
28 */
29 public class ExceptionEvent extends CommandResponseEvent {
30
31 private Throwable exception = null;
32
33 /***
34 * Creates the event for <code>command</code>.
35 *
36 * @param command The command that has started.
37 */
38 public ExceptionEvent(Command command, Throwable exception) {
39 super(command);
40 this.exception = exception;
41 }
42
43 /***
44 * Returns a SimpleMessage formatted as <code>[ <command-name> ] Started.</code>.
45 */
46 public Message getEventMessage() {
47 return new SimpleMessage(MessageHelper.format(getCommand().getName(), exception.getMessage()));
48 }
49
50 /***
51 * The exception that generated this event.
52 *
53 * @return The exception (as a <code>Throwable</code>) that caused this event to occur.
54 */
55 public Throwable getCause() {
56 return exception;
57 }
58 }