if (!argv) return JS_FALSE; errObject = js_ConstructObject(cx, &ExceptionClass, errProto, NULL, argc, argv); JS_PopArguments(cx, mark); if (!errObject) return JS_FALSE;
ok = InitExceptionObject(cx, errObject, messageStr, filenameStr, lineno); if (!ok) goto out;
js_ErrorToException(JSContext *cx, const char *message, JSErrorReport *reportp){    JSErrNum errorNumber;    JSExnType exn;    JSObject *errObject, *errProto;    uintN argc;    jsval *argv;    void *mark;    JSExnPrivate *privateData;    /* Find the exception index associated with this error. */    JS_ASSERT(reportp);    if (JSREPORT_IS_WARNING(reportp->flags))        return JS_FALSE;    errorNumber = (JSErrNum) reportp->errorNumber;    exn = errorToExceptionNum[errorNumber];    JS_ASSERT(exn < JSEXN_LIMIT);#if defined( DEBUG_mccabe ) && defined ( PRINTNAMES )    /* Print the error name and the associated exception name to stderr */    fprintf(stderr, "%s\t%s\n",	    errortoexnname[errorNumber].name,	    errortoexnname[errorNumber].exception);#endif    /*     * Return false (no exception raised) if no exception is associated     * with the given error number.     */    if (exn == JSEXN_NONE)	return JS_FALSE;    /*     * Try to get an appropriate prototype by looking up the corresponding     * exception constructor name in the scope chain of the current context's     * top stack frame, or in the global object if no frame is active.     *     * XXXbe hack around JSCLASS_NEW_RESOLVE code in js_LookupProperty that     *       checks cx->fp, cx->fp->pc, and js_CodeSpec[*cx->fp->pc] in order     *       to compute resolve flags such as JSRESOLVE_ASSIGNING.  The bug     *       is that this "internal" js_GetClassPrototype call may trigger a     *       resolve of exceptions[exn].name if the global object uses a lazy     *       standard class resolver (see JS_ResolveStandardClass), but the     *       current frame and bytecode end up affecting the resolve flags.     */    {        JSStackFrame *fp = cx->fp;        jsbytecode *pc = NULL;        JSBool ok;        if (fp) {            pc = fp->pc;            fp->pc = NULL;        }        ok = js_GetClassPrototype(cx, exceptions[exn].name, &errProto);        if (pc)            fp->pc = pc;        if (!ok)            return JS_FALSE;    }    /*     * Use js_ConstructObject to compute the stack property and any other     * default properties or private data.     */    if (reportp) {        argv = JS_PushArguments(cx, &mark, "ssu",                                message, reportp->filename, reportp->lineno);        argc = 3;    } else {        argv = JS_PushArguments(cx, &mark, "s", message);        argc = 1;    }    if (!argv)        return JS_FALSE;    errObject = js_ConstructObject(cx, &ExceptionClass, errProto, NULL,                                   argc, argv);    JS_PopArguments(cx, mark);    if (!errObject)        return JS_FALSE;    /*     * Construct a new copy of the error report, and store it in the     * exception objects' private data.  We can't use the error report     * handed in, because it's stack-allocated, and may point to transient     * data in the JSTokenStream.     */    privateData = exn_newPrivate(cx, reportp);    if (!privateData)        return JS_FALSE;    OBJ_SET_SLOT(cx, errObject, JSSLOT_PRIVATE, PRIVATE_TO_JSVAL(privateData));    /* Set the generated Exception object as the current exception. */    JS_SetPendingException(cx, OBJECT_TO_JSVAL(errObject));    /* Flag the error report passed in to indicate an exception was raised. */    reportp->flags |= JSREPORT_EXCEPTION;    return JS_TRUE;}