/* NB: An error object's private must be set through this function. */ static void SetExnPrivate(RawObject exnObject, JSExnPrivate *priv) { JS_ASSERT(!exnObject->getPrivate()); JS_ASSERT(exnObject->isError()); if (JSErrorReport *report = priv->errorReport) { if (JSPrincipals *prin = report->originPrincipals) JS_HoldPrincipals(prin); } exnObject->setPrivate(priv); }
JSErrorReport * js_ErrorFromException(jsval exn) { if (JSVAL_IS_PRIMITIVE(exn)) return NULL; RawObject obj = JSVAL_TO_OBJECT(exn); if (!obj->isError()) return NULL; JSExnPrivate *priv = GetExnPrivate(obj); if (!priv) return NULL; return priv->errorReport; }