Bug 957926 - Add JS::CreateTypeError. r=jorendorff

--HG--
extra : rebase_source : d621273cbff342f10864c2843a53eb55421fe582
This commit is contained in:
Nikhil Marathe 2014-01-28 09:19:48 -08:00
parent 676ef50617
commit 8c829fb1a0
2 changed files with 30 additions and 1 deletions

View File

@ -4455,6 +4455,15 @@ JS_GetErrorReporter(JSContext *cx);
extern JS_PUBLIC_API(JSErrorReporter)
JS_SetErrorReporter(JSContext *cx, JSErrorReporter er);
namespace JS {
extern JS_PUBLIC_API(bool)
CreateTypeError(JSContext *cx, HandleString stack, HandleString fileName,
uint32_t lineNumber, uint32_t columnNumber, JSErrorReport *report,
HandleString message, MutableHandleValue rval);
} /* namespace JS */
/************************************************************************/
/*
@ -4721,7 +4730,7 @@ class AutoHideScriptedCaller
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
};
} /* namepsace JS */
} /* namespace JS */
/*
* Encode/Decode interpreted scripts and functions to/from memory.

View File

@ -868,3 +868,23 @@ js_CopyErrorObject(JSContext *cx, Handle<ErrorObject*> err, HandleObject scope)
return ErrorObject::create(cx, errorType, stack, fileName,
lineNumber, columnNumber, &copyReport, message);
}
JS_PUBLIC_API(bool)
JS::CreateTypeError(JSContext *cx, HandleString stack, HandleString fileName,
uint32_t lineNumber, uint32_t columnNumber, JSErrorReport *report,
HandleString message, MutableHandleValue rval)
{
assertSameCompartment(cx, stack, fileName, message);
js::ScopedJSFreePtr<JSErrorReport> rep;
if (report)
rep = CopyErrorReport(cx, report);
RootedObject obj(cx,
js::ErrorObject::create(cx, JSEXN_TYPEERR, stack, fileName,
lineNumber, columnNumber, &rep, message));
if (!obj)
return false;
rval.setObject(*obj);
return true;
}