001    /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
002     *
003     * The contents of this file are subject to the Netscape Public
004     * License Version 1.1 (the "License"); you may not use this file
005     * except in compliance with the License. You may obtain a copy of
006     * the License at http://www.mozilla.org/NPL/
007     *
008     * Software distributed under the License is distributed on an "AS
009     * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
010     * implied. See the License for the specific language governing
011     * rights and limitations under the License.
012     *
013     * The Original Code is Rhino code, released
014     * May 6, 1999.
015     *
016     * The Initial Developer of the Original Code is Netscape
017     * Communications Corporation.  Portions created by Netscape are
018     * Copyright (C) 1997-1999 Netscape Communications Corporation. All
019     * Rights Reserved.
020     *
021     * Contributor(s):
022     * Norris Boyd
023     *
024     * Alternatively, the contents of this file may be used under the
025     * terms of the GNU Public License (the "GPL"), in which case the
026     * provisions of the GPL are applicable instead of those above.
027     * If you wish to allow use of your version of this file only
028     * under the terms of the GPL and not to allow others to use your
029     * version of this file under the NPL, indicate your decision by
030     * deleting the provisions above and replace them with the notice
031     * and other provisions required by the GPL.  If you do not delete
032     * the provisions above, a recipient may use your version of this
033     * file under either the NPL or the GPL.
034     */
035    // Modified by Google
036    
037    // API class
038    
039    package com.google.gwt.dev.js.rhino;
040    
041    
042    /**
043     * Java reflection of JavaScript exceptions.  (Possibly wrapping a Java exception.)
044     */
045    public class JavaScriptException extends Exception {
046    
047        /**
048         * Create a JavaScript exception wrapping the given JavaScript value.
049         *
050         * Instances of this class are thrown by the JavaScript 'throw' keyword.
051         *
052         * @param value the JavaScript value thrown.
053         */
054        public JavaScriptException(Object value) {
055            super(value.toString());
056            this.value = value;
057        }
058    
059        /**
060         * Get the exception value originally thrown.  This may be a
061         * JavaScript value (null, undefined, Boolean, Number, String,
062         * Scriptable or Function) or a Java exception value thrown from a
063         * host object or from Java called through LiveConnect.
064         *
065         * @return the value wrapped by this exception
066         */
067        public Object getValue() {
068            return value;
069        }
070    
071        /**
072         * The JavaScript exception value.  This value is not
073         * intended for general use; if the JavaScriptException wraps a
074         * Java exception, getScriptableValue may return a Scriptable
075         * wrapping the original Java exception object.
076         *
077         * We would prefer to go through a getter to encapsulate the value,
078         * however that causes the bizarre error "nanosecond timeout value
079         * out of range" on the MS JVM.
080         * @serial
081         */
082        Object value;
083    }