mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-11 22:41:02 +00:00
Bug 957926 - Add JS::CreateTypeError. r=jorendorff
--HG-- extra : rebase_source : d621273cbff342f10864c2843a53eb55421fe582
This commit is contained in:
parent
676ef50617
commit
8c829fb1a0
@ -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.
|
||||
|
@ -868,3 +868,23 @@ js_CopyErrorObject(JSContext *cx, Handle<ErrorObject*> err, HandleObject scope)
|
||||
return ErrorObject::create(cx, errorType, stack, fileName,
|
||||
lineNumber, columnNumber, ©Report, 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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user