msg = ((JavaScriptException) x).getValue().toString();
msg = ((JavaScriptException) x).getMessage();
    public Object invoke(Object thisObject, String functionName, Object[] args,                         int argsWrapMode) throws ScriptingException {        Scriptable eso = null;        if (thisObject == null) {            eso = global;        } else {            eso = Context.toObject(thisObject, global);        }        try {            for (int i = 0; i < args.length; i++) {                switch (argsWrapMode) {                    case ARGS_WRAP_DEFAULT:                        // convert java objects to JavaScript                        if (args[i] != null) {                            args[i] = Context.javaToJS(args[i], global);                        }                        break;                    case ARGS_WRAP_XMLRPC:                        // XML-RPC requires special argument conversion                        args[i] = core.processXmlRpcArgument(args[i]);                        break;                }            }            Object f = ScriptableObject.getProperty(eso, functionName.replace('.', '_'));            if ((f == ScriptableObject.NOT_FOUND) || !(f instanceof Function)) {                return null;            }            Object retval = ((Function) f).call(context, global, eso, args);            if (retval instanceof Wrapper) {                retval = ((Wrapper) retval).unwrap();            }            if ((retval == null) || (retval == Undefined.instance)) {                return null;            } else if (argsWrapMode == ARGS_WRAP_XMLRPC) {                return core.processXmlRpcResponse (retval);            } else {                return retval;            }        } catch (RedirectException redirect) {            throw redirect;        } catch (TimeoutException timeout) {            throw timeout;        } catch (ConcurrencyException concur) {            throw concur;        } catch (Exception x) {            // has the request timed out? If so, throw TimeoutException            if (thread != Thread.currentThread())                throw new TimeoutException ();            // create and throw a ScriptingException with the right message            String msg;            if (x instanceof JavaScriptException) {                msg = ((JavaScriptException) x).getValue().toString();            } else if (x instanceof WrappedException) {                Throwable wrapped = ((WrappedException) x).getWrappedException();                // if this is a wrapped concurrencyException, rethrow it.                if (wrapped instanceof ConcurrencyException) {                    throw (ConcurrencyException) wrapped;                }                // also check if this is a wrapped redirect exception                if (wrapped instanceof RedirectException) {                    throw (RedirectException) wrapped;                }                msg = wrapped.toString();            } else {                msg = x.toString();            }            if (app.debug()) {                System.err.println("Error in Script: " + msg);                x.printStackTrace();            }            throw new ScriptingException(msg);        }    }