1 package siouxsie.mvc.impl;
2
3 import javax.swing.JOptionPane;
4
5 import org.apache.commons.logging.Log;
6 import org.apache.commons.logging.LogFactory;
7 import org.jdesktop.swingx.JXErrorPane;
8 import org.jdesktop.swingx.error.ErrorInfo;
9
10 import com.opensymphony.xwork2.ActionInvocation;
11 import com.opensymphony.xwork2.Result;
12 import com.opensymphony.xwork2.interceptor.ExceptionHolder;
13
14 /**
15 * Simple exception handler using a modal dialog.
16 * @author Arnaud Cogoluegnes
17 * @version $Id$
18 */
19 public class ExceptionHandler implements Result {
20
21 /**
22 *
23 */
24 private static final long serialVersionUID = 3167688293250093026L;
25
26 private static final Log LOG = LogFactory.getLog(ExceptionHandler.class);
27
28 private String title = "Error";
29
30 private String message = "An error has occurred!";
31
32
33
34
35
36 public void execute(ActionInvocation invocation) throws Exception {
37
38 ExceptionHolder holder = (ExceptionHolder) invocation.getStack().peek();
39
40 Exception ex = holder.getException();
41
42 LOG.error(ex.getMessage(),ex);
43 ErrorInfo info = new ErrorInfo(
44 getTitle(),
45 getMessage(),
46 null,
47 null,
48 ex,
49 null,null
50 );
51 JXErrorPane.showDialog(
52 JOptionPane.getRootFrame(),
53 info
54 );
55
56 }
57
58 public String getTitle() {
59 return title;
60 }
61
62 public void setTitle(String title) {
63 this.title = title;
64 }
65
66 public String getMessage() {
67 return message;
68 }
69
70 public void setMessage(String message) {
71 this.message = message;
72 }
73
74
75
76 }