Skip to content
Snippets Groups Projects
Commit bf55821f authored by rswindell's avatar rswindell
Browse files

Created js.report_error() function for reporting errors (fatal or not) using

the standard JS error reporting mechanism. Not recommended for most
script-level error logging.
parent ad538657
No related branches found
No related tags found
No related merge requests found
...@@ -301,6 +301,16 @@ js_gc(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) ...@@ -301,6 +301,16 @@ js_gc(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
return(JS_TRUE); return(JS_TRUE);
} }
static JSBool
js_report_error(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
JS_ReportError(cx,"%s",JS_GetStringBytes(JS_ValueToString(cx, argv[0])));
if(argc>1 && argv[1]==JSVAL_TRUE)
return(JS_FALSE); /* fatal */
return(JS_TRUE);
}
static JSClass js_internal_class = { static JSClass js_internal_class = {
"JsInternal" /* name */ "JsInternal" /* name */
...@@ -325,7 +335,13 @@ static jsSyncMethodSpec js_functions[] = { ...@@ -325,7 +335,13 @@ static jsSyncMethodSpec js_functions[] = {
"if <i>forced</i> is <i>true</i> (the default) a garbage collection is always performed, " "if <i>forced</i> is <i>true</i> (the default) a garbage collection is always performed, "
"otherwise it is only performed if deemed appropriate by the JavaScript engine") "otherwise it is only performed if deemed appropriate by the JavaScript engine")
,311 ,311
}, },
{"report_error", js_report_error, 1, JSTYPE_VOID, JSDOCSTR("error [, bool fatal]")
,JSDOCSTR("report an error using the standard JavaScript error reporting mechanism "
"(including script filename and line number), "
"if <i>fatal</i> is <i>true</i>, terminates script - (added in v3.12b)")
,312
},
{0} {0}
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment