View Javadoc

1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See the file AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation.
9    *
10   *  This program is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *  GNU General Public License for more details.
14   *
15   *  You should have received a copy of the GNU General Public License
16   *  along with this program; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  
20  package org.xnap.plugin.gift.net.event;
21  
22  /***
23   * ErrorEvent
24   *
25   * @author <a href="mailto:tvanlessen@taval.de">Tammo van Lessen</a>
26   * @version CVS $Id: ErrorEvent.java,v 1.1 2003/10/05 00:20:32 squig Exp $
27   */
28  public class ErrorEvent extends Event {
29      //~ Instance fields --------------------------------------------------------
30  
31      private Exception e;
32      private String msg;
33  
34      //~ Constructors -----------------------------------------------------------
35  
36      /***
37       * Constructor for ErrorEvent.
38       *
39       * @param msg Message
40       */
41      public ErrorEvent(String msg) {
42          super();
43          this.msg = msg;
44          this.e = null;
45      }
46  
47      /***
48       * Creates a new ErrorEvent object.
49       *
50       * @param msg Message
51       * @param e Exception
52       */
53      public ErrorEvent(String msg, Exception e) {
54          super();
55          this.msg = msg;
56          this.e = e;
57      }
58  
59      /***
60       * Creates a new ErrorEvent object.
61       *
62       * @param e Exception
63       */
64      public ErrorEvent(Exception e) {
65          super();
66          this.msg = null;
67          this.e = e;
68      }
69  
70      //~ Methods ----------------------------------------------------------------
71  
72      /***
73       * Returns the msg.
74       *
75       * @return String
76       */
77      public String getErrorMessage() {
78          return msg;
79      }
80  
81      /***
82       * Returns the exception.
83       *
84       * @return Exception
85       */
86      public Exception getException() {
87          return e;
88      }
89  
90      /***
91       * @see java.lang.Object#toString()
92       */
93      public String toString() {
94          return "Network Error (" + getErrorMessage() + ")";
95      }
96  }