Bug 914014: Use WrapObject to wrap nsIExceptions rather than manual XPConnect gunk. r=bz

This commit is contained in:
Kyle Huey 2013-09-23 11:35:09 +08:00
parent 9a3bd8e476
commit b7e9e474ac

View File

@ -58,21 +58,12 @@ ThrowExceptionObject(JSContext* aCx, nsIException* aException)
return false;
}
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
nsresult rv = nsContentUtils::XPConnect()->WrapNative(aCx, glob, aException,
NS_GET_IID(nsIException),
getter_AddRefs(holder));
if (NS_FAILED(rv) ||! holder) {
JS::Rooted<JS::Value> val(aCx);
if (!WrapObject(aCx, glob, aException, &NS_GET_IID(nsIException), &val)) {
return false;
}
JS::RootedObject obj(aCx, holder->GetJSObject());
if (!obj) {
return false;
}
JS::RootedValue exn(aCx, JS::ObjectOrNullValue(obj));
JS_SetPendingException(aCx, exn);
JS_SetPendingException(aCx, val);
return true;
}