root/Trunk/SpeechSubmission/VFSpeechSubmission/java/src/netscape/javascript/JSException.java
| Revision 2245, 3.7 kB (checked in by kmaclean, 1 year ago) |
|---|
| Line | |
|---|---|
| 1 | /* -*- Mode: Java; tab-width: 8; c-basic-offset: 4 -*- |
| 2 | |
| 3 | This program is free software; you can redistribute it and/or |
| 4 | modify it under the terms of the GNU General Public License |
| 5 | as published by the Free Software Foundation; either version 2 |
| 6 | of the License, or (at your option) any later version. |
| 7 | |
| 8 | This program is distributed in the hope that it will be useful, |
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | GNU General Public License for more details. |
| 12 | |
| 13 | You should have received a copy of the GNU General Public License |
| 14 | along with this program; if not, write to the Free Software |
| 15 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
| 16 | |
| 17 | package netscape.javascript; |
| 18 | |
| 19 | /** |
| 20 | * JSException is an exception which is thrown when JavaScript code returns an error. |
| 21 | */ |
| 22 | |
| 23 | public |
| 24 | class JSException extends RuntimeException { |
| 25 | public static final int EXCEPTION_TYPE_EMPTY = -1; |
| 26 | public static final int EXCEPTION_TYPE_VOID = 0; |
| 27 | public static final int EXCEPTION_TYPE_OBJECT = 1; |
| 28 | public static final int EXCEPTION_TYPE_FUNCTION = 2; |
| 29 | public static final int EXCEPTION_TYPE_STRING = 3; |
| 30 | public static final int EXCEPTION_TYPE_NUMBER = 4; |
| 31 | public static final int EXCEPTION_TYPE_BOOLEAN = 5; |
| 32 | public static final int EXCEPTION_TYPE_ERROR = 6; |
| 33 | |
| 34 | String filename; |
| 35 | int lineno; |
| 36 | String source; |
| 37 | int tokenIndex; |
| 38 | private int wrappedExceptionType; |
| 39 | private Object wrappedException; |
| 40 | |
| 41 | /** |
| 42 | * Constructs a JSException without a detail message. |
| 43 | * A detail message is a String that describes this particular exception. |
| 44 | * |
| 45 | * @deprecated Not for public use in future versions. |
| 46 | */ |
| 47 | public JSException() { |
| 48 | super(); |
| 49 | filename = "unknown"; |
| 50 | lineno = 0; |
| 51 | source = ""; |
| 52 | tokenIndex = 0; |
| 53 | wrappedExceptionType = EXCEPTION_TYPE_EMPTY; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Constructs a JSException with a detail message. |
| 58 | * A detail message is a String that describes this particular exception. |
| 59 | * @param s the detail message |
| 60 | * |
| 61 | * @deprecated Not for public use in future versions. |
| 62 | */ |
| 63 | public JSException(String s) { |
| 64 | super(s); |
| 65 | filename = "unknown"; |
| 66 | lineno = 0; |
| 67 | source = ""; |
| 68 | tokenIndex = 0; |
| 69 | wrappedExceptionType = EXCEPTION_TYPE_EMPTY; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Constructs a JSException with a wrapped JavaScript exception object. |
| 74 | * This constructor needs to be public so that Java users can throw |
| 75 | * exceptions to JS cleanly. |
| 76 | */ |
| 77 | private JSException(int wrappedExceptionType, Object wrappedException) { |
| 78 | super(); |
| 79 | this.wrappedExceptionType = wrappedExceptionType; |
| 80 | this.wrappedException = wrappedException; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Constructs a JSException with a detail message and all the |
| 85 | * other info that usually comes with a JavaScript error. |
| 86 | * @param s the detail message |
| 87 | * |
| 88 | * @deprecated Not for public use in future versions. |
| 89 | */ |
| 90 | public JSException(String s, String filename, int lineno, |
| 91 | String source, int tokenIndex) { |
| 92 | super(s); |
| 93 | this.filename = filename; |
| 94 | this.lineno = lineno; |
| 95 | this.source = source; |
| 96 | this.tokenIndex = tokenIndex; |
| 97 | wrappedExceptionType = EXCEPTION_TYPE_EMPTY; |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Instance method getWrappedExceptionType returns the int mapping of the type of the wrappedException Object. |
| 102 | * @uml.property name="wrappedExceptionType" |
| 103 | */ |
| 104 | public int getWrappedExceptionType() { |
| 105 | return wrappedExceptionType; |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Instance method getWrappedException. |
| 110 | * @uml.property name="wrappedException" |
| 111 | */ |
| 112 | public Object getWrappedException() { |
| 113 | return wrappedException; |
| 114 | } |
| 115 | |
| 116 | } |
| 117 |
Note: See TracBrowser for help on using the browser.