User-defined exceptions are dumped as a plain json object without calling their toString() - this can lose valuable bits of information. For test262 purposes, for example, class name information is lost:
$ cat exc.js
function Test262Error(message) {
this.message = message || "";
}
Test262Error.prototype.toString = function () {
return "Test262Error: " + this.message;
};
throw new Test262Error("foo");
$ ./qjs exc.js
{ message: "foo" }
In contrast, for standard exceptions:
$ ./qjs -e 'throw new RangeError("foo");'
RangeError: foo
at <eval> (<cmdline>:1:21)
quickjs-ng gets it right.
js_std_dump_error1 should switch from JS_PrintValue to JS_ToCString.
A stack trace would be nice too, but probably more work.
User-defined exceptions are dumped as a plain json object without calling their toString() - this can lose valuable bits of information. For test262 purposes, for example, class name information is lost:
In contrast, for standard exceptions:
quickjs-ng gets it right.
js_std_dump_error1should switch fromJS_PrintValuetoJS_ToCString.A stack trace would be nice too, but probably more work.