Re: what is the replacement of JS_SetErrorReporter in spidermonkey 60
Kent Williams <[email protected]> Wed, 10 Apr 2019 14:54:48 -0500
| Newsgroups | gmane.comp.mozilla.devel.jseng |
|---|---|
| Message-ID | <[email protected]> |
Well it's replaced by JS::SetWarningReporter.
That will report warnings.
You also probably want to catch exceptions that abort script evaluation,
which you do by code kind of like this, if JS_ExecuteScript returns
false, call this guy to report errors.
void ReportJSException(JSContext *context) {
if(JS_IsExceptionPending(context)) {
JS::RootedValue exception(context);
if(JS_GetPendingException(context,&exception) &&
exception.isObject()) {
JS::AutoSaveExceptionState savedExc(context);
JS::Rooted<JSObject*> exceptionObject(context,
&exception.toObject());
JSErrorReport *what =
JS_ErrorFromException(context,exceptionObject);
if(what) {
std::cerr << "compilation exception: " << what->message;
std::cerr << ": file: " << what->filename;
std::cerr << ", line: " << (int) what->lineno << "\n";
}
}
JS_ClearPendingException(context);
}
}
On 4/10/19 2:36 PM, msami wrote:
> I want to report errors from js engine to c++ code side.
> _______________________________________________
> dev-tech-js-engine mailing list
> [email protected]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine
_______________________________________________
dev-tech-js-engine mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine