1 /* 2 * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package netscape.javascript; 27 28 29 /** 30 * <p> Thrown when an exception is raised in the JavaScript engine. 31 * </p> 32 * 33 * <p> Much of the functionality in this class is deprecated as it is 34 * not portable between web browsers. The only functionality that 35 * should be relied upon is the throwing of this exception and calls 36 * to <CODE>printStackTrace()</CODE>. </p> 37 */ 38 public class JSException extends RuntimeException { 39 40 // Exception type supported by JavaScript 1.4 in Navigator 5.0. 41 // 42 /** @deprecated Not portable between web browsers. */ 43 public static final int EXCEPTION_TYPE_EMPTY = -1; 44 /** @deprecated Not portable between web browsers. */ 45 public static final int EXCEPTION_TYPE_VOID = 0; 46 /** @deprecated Not portable between web browsers. */ 47 public static final int EXCEPTION_TYPE_OBJECT = 1; 48 /** @deprecated Not portable between web browsers. */ 49 public static final int EXCEPTION_TYPE_FUNCTION = 2; 50 /** @deprecated Not portable between web browsers. */ 51 public static final int EXCEPTION_TYPE_STRING = 3; 52 /** @deprecated Not portable between web browsers. */ 53 public static final int EXCEPTION_TYPE_NUMBER = 4; 54 /** @deprecated Not portable between web browsers. */ 55 public static final int EXCEPTION_TYPE_BOOLEAN = 5; 56 /** @deprecated Not portable between web browsers. */ 57 public static final int EXCEPTION_TYPE_ERROR = 6; 58 59 /** 60 * <p> Constructs a JSException object. 61 * </p> 62 */ 63 public JSException() { 64 this(null); 65 } 66 67 /** 68 * <p> Construct a JSException object with a detail message. 69 * </p> 70 * 71 * @param s The detail message 72 */ 73 public JSException(String s) { 74 this(s, null, -1, null, -1); 75 } 76 77 78 /** 79 * <p> Construct a JSException object. This constructor is 80 * deprecated as it involves non-portable functionality. </p> 81 * 82 * @param s The detail message. 83 * @param filename The URL of the file where the error occurred, if possible. 84 * @param lineno The line number if the file, if possible. 85 * @param source The string containing the JavaScript code being evaluated. 86 * @param tokenIndex The index into the source string where the error occurred. 87 * @deprecated Not portable between web browsers. 88 */ 89 public JSException(String s, String filename, int lineno, String source, 90 int tokenIndex) { 91 super(s); 92 this.message = s; 93 this.filename = filename; 94 this.lineno = lineno; 95 this.source = source; 96 this.tokenIndex = tokenIndex; 97 this.wrappedExceptionType = EXCEPTION_TYPE_EMPTY; 98 } 99 100 /** 101 * <p> Construct a JSException object. This constructor is 102 * deprecated as it involves non-portable functionality. </p> 103 * 104 * @param wrappedExceptionType Type of the wrapped JavaScript exception. 105 * @param wrappedException JavaScript exception wrapper. 106 * @deprecated Not portable between web browsers. 107 */ 108 public JSException(int wrappedExceptionType, Object wrappedException) { 109 this(); 110 this.wrappedExceptionType = wrappedExceptionType; 111 this.wrappedException = wrappedException; 112 } 113 114 /** 115 * <p> The detail message. </p> 116 * @deprecated Not portable between web browsers. 117 */ 118 protected String message = null; 119 120 /** 121 * <p> The URL of the file where the error occurred, if possible. </p> 122 * @deprecated Not portable between web browsers. 123 */ 124 protected String filename = null; 125 126 /** 127 * <p> The line number if the file, if possible. </p> 128 * @deprecated Not portable between web browsers. 129 */ 130 protected int lineno = -1; 131 132 /** 133 * <p> The string containing the JavaScript code being evaluated. </p> 134 * @deprecated Not portable between web browsers. 135 */ 136 protected String source = null; 137 138 /** 139 * <p> The index into the source string where the error occurred. </p> 140 * @deprecated Not portable between web browsers. 141 */ 142 protected int tokenIndex = -1; 143 144 /** 145 * <p> Type of the wrapped JavaScript exception. </p> 146 * @deprecated Not portable between web browsers. 147 */ 148 private int wrappedExceptionType = -1; 149 150 /** 151 * <p> JavaScript exception wrapper. </p> 152 * @deprecated Not portable between web browsers. 153 */ 154 private Object wrappedException = null; 155 156 /** 157 * <P> getWrappedExceptionType returns the int mapping of the type 158 * of the wrappedException Object. This method is deprecated as it 159 * involves non-portable functionality. </P> 160 * 161 * @return int JavaScript exception type. 162 * @deprecated Not portable between web browsers. 163 */ 164 public int getWrappedExceptionType() { 165 return wrappedExceptionType; 166 } 167 168 /** 169 * <P> Returns the wrapped JavaScript exception. This method is 170 * deprecated as it involves non-portable functionality. </P> 171 * 172 * @return Object JavaScript exception wrapper. 173 * @deprecated Not portable between web browsers. 174 */ 175 public Object getWrappedException() { 176 return wrappedException; 177 } 178 }