View Javadoc
1   /*
2    * Copyright (c) 2002-2017 Gargoyle Software Inc.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */
15  package netscape.javascript;
16  
17  /**
18   * Stub for the JSException. This is part of the Applet
19   * LiveConnect simulation.
20   *
21   * TODO: we have to evaluate if it is possible to use plugin.jar from jdk
22   *
23   * @author Ronald Brill
24   */
25  public class JSException extends RuntimeException {
26      /** EXCEPTION_TYPE_EMPTY = -1. */
27      public static final int EXCEPTION_TYPE_EMPTY = -1;
28  
29      /** EXCEPTION_TYPE_VOID = 0. */
30      public static final int EXCEPTION_TYPE_VOID = 0;
31  
32      /** EXCEPTION_TYPE_OBJECT = 1. */
33      public static final int EXCEPTION_TYPE_OBJECT = 1;
34  
35      /** EXCEPTION_TYPE_FUNCTION = 2. */
36      public static final int EXCEPTION_TYPE_FUNCTION = 2;
37  
38      /** EXCEPTION_TYPE_STRING = 3. */
39      public static final int EXCEPTION_TYPE_STRING = 3;
40  
41      /** EXCEPTION_TYPE_NUMBER = 4. */
42      public static final int EXCEPTION_TYPE_NUMBER = 4;
43  
44      /** EXCEPTION_TYPE_BOOLEAN = 5. */
45      public static final int EXCEPTION_TYPE_BOOLEAN = 5;
46  
47      /** EXCEPTION_TYPE_ERROR = 6. */
48      public static final int EXCEPTION_TYPE_ERROR = 6;
49  
50      /** wrappedExceptionType. */
51      private int wrappedExceptionType_ = EXCEPTION_TYPE_EMPTY;
52  
53      /** wrappedException. */
54      private Object wrappedException_;
55  
56      /**
57       * Constructor.
58       */
59      public JSException() {
60          this(null);
61      }
62  
63      /**
64       * Constructor.
65       * @param message the message
66       */
67      public JSException(final String message) {
68          this(message, null, -1, null, -1);
69      }
70  
71      /**
72       * Constructor.
73       * @param message the message
74       * @param filename the filename
75       * @param lineno the lineno
76       * @param source the source
77       * @param tokenIndex the tokenIndex
78       */
79      public JSException(final String message,
80              final String filename, final int lineno,
81              final String source, final int tokenIndex) {
82          super(message);
83      }
84  
85      /**
86       * Constructor.
87       * @param exceptionType the exception type
88       * @param exception the exception
89       */
90      public JSException(final int exceptionType, final Object exception) {
91          this();
92          wrappedExceptionType_ = exceptionType;
93          wrappedException_ = exception;
94      }
95  
96      /**
97       * Returns the wrapped exception type.
98       * @return wrapped exception type
99       */
100     public int getWrappedExceptionType() {
101         return wrappedExceptionType_;
102     }
103 
104     /**
105      * Returns the wrapped exception.
106      * @return wrapped exception
107      */
108     public Object getWrappedException() {
109         return wrappedException_;
110     }
111 }