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

Fix require(): if load() fails with exception, don't report a "symbol

not defined" exception, just report the load() exception - whatever it was
(e.g. could not open load-file).
parent be5d0919
No related branches found
No related tags found
No related merge requests found
......@@ -723,12 +723,13 @@ js_require(JSContext *cx, uintN argc, jsval *arglist)
ret = js_load(cx, argc-1, arglist);
// TODO: this error is happening if the file doesn't exist!
if (!JS_HasProperty(cx, exec_obj, property, &found) || !found) {
JSVALUE_TO_MSTRING(cx, argv[fnarg], filename, NULL);
JS_ReportError(cx,"symbol '%s' not defined by script '%s'", property, filename);
free(filename);
return(JS_FALSE);
if (!JS_IsExceptionPending(cx)) {
if (!JS_HasProperty(cx, exec_obj, property, &found) || !found) {
JSVALUE_TO_MSTRING(cx, argv[fnarg], filename, NULL);
JS_ReportError(cx,"symbol '%s' not defined by script '%s'", property, filename);
free(filename);
return(JS_FALSE);
}
}
free(property);
return ret;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment