Spec-Zone .ru
спецификации, руководства, описания, API
001/*
002 * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
003 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
004 */
005
006package netscape.javascript;
007
008
009/**
010 * <p> Thrown when an exception is raised in the JavaScript engine.
011 * </p>
012 *
013 * <p> Much of the functionality in this class is deprecated as it is
014 * not portable between web browsers. The only functionality that
015 * should be relied upon is the throwing of this exception and calls
016 * to <CODE>printStackTrace()</CODE>. </p>
017 */
018public class JSException extends RuntimeException {
019
020    // Exception type supported by JavaScript 1.4 in Navigator 5.0.
021    //
022    /** @deprecated  Not portable between web browsers. */
023    public static final int EXCEPTION_TYPE_EMPTY = -1;
024    /** @deprecated  Not portable between web browsers. */
025    public static final int EXCEPTION_TYPE_VOID = 0;
026    /** @deprecated  Not portable between web browsers. */
027    public static final int EXCEPTION_TYPE_OBJECT = 1;
028    /** @deprecated  Not portable between web browsers. */
029    public static final int EXCEPTION_TYPE_FUNCTION = 2;
030    /** @deprecated  Not portable between web browsers. */
031    public static final int EXCEPTION_TYPE_STRING = 3;
032    /** @deprecated  Not portable between web browsers. */
033    public static final int EXCEPTION_TYPE_NUMBER = 4;
034    /** @deprecated  Not portable between web browsers. */
035    public static final int EXCEPTION_TYPE_BOOLEAN = 5;
036    /** @deprecated  Not portable between web browsers. */
037    public static final int EXCEPTION_TYPE_ERROR = 6;
038
039    /**
040     * <p> Constructs a JSException object.
041     * </p>
042     */
043    public JSException() {
044        this(null);
045    }
046
047    /**
048     * <p> Construct a JSException object with a detail message.
049     * </p>
050     *
051     * @param s The detail message
052     */
053     public JSException(String s)  {
054        this(s, null, -1, null, -1);
055    }
056
057
058    /**
059     * <p> Construct a JSException object. This constructor is
060     * deprecated as it involves non-portable functionality. </p>
061     *
062     * @param s The detail message.
063     * @param filename The URL of the file where the error occurred, if possible.
064     * @param lineno The line number if the file, if possible.
065     * @param source The string containing the JavaScript code being evaluated.
066     * @param tokenIndex The index into the source string where the error occurred.
067     * @deprecated  Not portable between web browsers.
068     */
069    public JSException(String s, String filename, int lineno, String source,
070                       int tokenIndex)  {
071        super(s);
072        this.message = s;
073        this.filename = filename;
074        this.lineno = lineno;
075        this.source = source;
076        this.tokenIndex = tokenIndex;
077        this.wrappedExceptionType = EXCEPTION_TYPE_EMPTY;
078    }
079
080    /**
081     * <p> Construct a JSException object. This constructor is
082     * deprecated as it involves non-portable functionality. </p>
083     *
084     * @param wrappedExceptionType Type of the wrapped JavaScript exception.
085     * @param wrappedException JavaScript exception wrapper.
086     * @deprecated  Not portable between web browsers.
087     */
088    public JSException(int wrappedExceptionType, Object wrappedException) {
089        this();
090        this.wrappedExceptionType = wrappedExceptionType;
091        this.wrappedException = wrappedException;
092    }
093
094    /**
095     * <p> The detail message. </p>
096     * @deprecated  Not portable between web browsers.
097     */
098    protected String message = null;
099
100    /**
101     * <p> The URL of the file where the error occurred, if possible. </p>
102     * @deprecated  Not portable between web browsers.
103     */
104    protected String filename = null;
105
106    /**
107     * <p> The line number if the file, if possible. </p>
108     * @deprecated  Not portable between web browsers.
109     */
110    protected int lineno = -1;
111
112    /**
113     * <p> The string containing the JavaScript code being evaluated. </p>
114     * @deprecated  Not portable between web browsers.
115     */
116    protected String source = null;
117
118    /**
119     * <p> The index into the source string where the error occurred. </p>
120     * @deprecated  Not portable between web browsers.
121     */
122    protected int tokenIndex = -1;
123
124    /**
125     * <p> Type of the wrapped JavaScript exception. </p>
126     * @deprecated  Not portable between web browsers.
127     */
128    private int wrappedExceptionType = -1;
129
130    /**
131     * <p> JavaScript exception wrapper. </p>
132     * @deprecated  Not portable between web browsers.
133     */
134    private Object wrappedException = null;
135
136    /**
137     * <P> getWrappedExceptionType returns the int mapping of the type
138     * of the wrappedException Object. This method is deprecated as it
139     * involves non-portable functionality.  </P>
140     *
141     * @return int JavaScript exception type.
142     * @deprecated  Not portable between web browsers.
143     */
144    public int getWrappedExceptionType() {
145        return wrappedExceptionType;
146    }
147
148    /**
149     * <P> Returns the wrapped JavaScript exception. This method is
150     * deprecated as it involves non-portable functionality.  </P>
151     *
152     * @return Object JavaScript exception wrapper.
153     * @deprecated  Not portable between web browsers.
154     */
155    public Object getWrappedException() {
156        return wrappedException;
157    }
158}