Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/simscomputing/IllegalStateException.java


1   // Copyright 2000 Sims Computing, Inc.
2   // Licensed under the GNU Lesser General Public License.
3   
4   package com.simscomputing;
5   
6   /**
7   Indicates that an error has been detected in the software's design or
8   implementation. Provides the same functionality as
9   java.lang.IllegalStateException except that it also allows an
10  exception to be encapsulated.
11  
12  @author David Sims
13  @version $Revision: 1.1.1.1 $ $Date: 2000/02/21 21:22:33 $
14  */
15  public class IllegalStateException extends java.lang.IllegalStateException {
16    private Throwable exception;
17  
18    // note: there is no default constructor because these kinds of
19    // exceptions are important enough to require an error message
20    // as shown in the following constructors.
21  
22    /**
23    Indicates that a software bug was found. The reason for the bug is listed
24    in the specified error message.
25  
26    @param String the error message
27    @precondition message != null
28    */
29    public IllegalStateException(String message) {
30      super(message);
31  
32      if (message == null) {
33        throw new NullPointerException("message is null");
34      } // if
35    } // constructor
36  
37    /**
38    Use this constructor to include an exception that was the cause of
39    the software fault.
40  
41    @param String the error message
42    @param Throwable the exception that triggered the bug
43    @precondition message != null && exception != null
44    */
45    public IllegalStateException(String message, Throwable exception) {
46      super(message);
47  
48      if (message == null) {
49        throw new NullPointerException("message is null");
50      } // if
51  
52      if (exception == null) {
53        throw new NullPointerException("exception is null");
54      } // if
55  
56      this.exception = exception;
57    } // constructor
58  
59    // fixme: probably want to override methods from Throwable: look at ImpossibleExceptionException
60    public Throwable getException() {
61      return exception;
62    } // getException()
63  } // SoftwareFaultException