mirror of
https://github.com/bellard/quickjs.git
synced 2024-11-22 13:48:11 +08:00
added Error cause
This commit is contained in:
parent
2ee6be705f
commit
5c120cd471
2
TODO
2
TODO
@ -63,5 +63,5 @@ Optimization ideas:
|
|||||||
Test262o: 0/11262 errors, 463 excluded
|
Test262o: 0/11262 errors, 463 excluded
|
||||||
Test262o commit: 7da91bceb9ce7613f87db47ddd1292a2dda58b42 (es5-tests branch)
|
Test262o commit: 7da91bceb9ce7613f87db47ddd1292a2dda58b42 (es5-tests branch)
|
||||||
|
|
||||||
Result: 16/76773 errors, 1497 excluded, 8204 skipped
|
Result: 16/76783 errors, 1497 excluded, 8199 skipped
|
||||||
Test262 commit: 6cbb6da9473c56d95358d8e679c5a6d2b4574efb
|
Test262 commit: 6cbb6da9473c56d95358d8e679c5a6d2b4574efb
|
||||||
|
@ -82,6 +82,7 @@ DEF(length, "length")
|
|||||||
DEF(fileName, "fileName")
|
DEF(fileName, "fileName")
|
||||||
DEF(lineNumber, "lineNumber")
|
DEF(lineNumber, "lineNumber")
|
||||||
DEF(message, "message")
|
DEF(message, "message")
|
||||||
|
DEF(cause, "cause")
|
||||||
DEF(errors, "errors")
|
DEF(errors, "errors")
|
||||||
DEF(stack, "stack")
|
DEF(stack, "stack")
|
||||||
DEF(name, "name")
|
DEF(name, "name")
|
||||||
|
26
quickjs.c
26
quickjs.c
@ -38204,7 +38204,8 @@ static JSValue js_error_constructor(JSContext *ctx, JSValueConst new_target,
|
|||||||
int argc, JSValueConst *argv, int magic)
|
int argc, JSValueConst *argv, int magic)
|
||||||
{
|
{
|
||||||
JSValue obj, msg, proto;
|
JSValue obj, msg, proto;
|
||||||
JSValueConst message;
|
JSValueConst message, options;
|
||||||
|
int arg_index;
|
||||||
|
|
||||||
if (JS_IsUndefined(new_target))
|
if (JS_IsUndefined(new_target))
|
||||||
new_target = JS_GetActiveFunction(ctx);
|
new_target = JS_GetActiveFunction(ctx);
|
||||||
@ -38230,12 +38231,9 @@ static JSValue js_error_constructor(JSContext *ctx, JSValueConst new_target,
|
|||||||
JS_FreeValue(ctx, proto);
|
JS_FreeValue(ctx, proto);
|
||||||
if (JS_IsException(obj))
|
if (JS_IsException(obj))
|
||||||
return obj;
|
return obj;
|
||||||
if (magic == JS_AGGREGATE_ERROR) {
|
arg_index = (magic == JS_AGGREGATE_ERROR);
|
||||||
message = argv[1];
|
|
||||||
} else {
|
|
||||||
message = argv[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
message = argv[arg_index++];
|
||||||
if (!JS_IsUndefined(message)) {
|
if (!JS_IsUndefined(message)) {
|
||||||
msg = JS_ToString(ctx, message);
|
msg = JS_ToString(ctx, message);
|
||||||
if (unlikely(JS_IsException(msg)))
|
if (unlikely(JS_IsException(msg)))
|
||||||
@ -38244,6 +38242,22 @@ static JSValue js_error_constructor(JSContext *ctx, JSValueConst new_target,
|
|||||||
JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
|
JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (arg_index < argc) {
|
||||||
|
options = argv[arg_index];
|
||||||
|
if (JS_IsObject(options)) {
|
||||||
|
int present = JS_HasProperty(ctx, options, JS_ATOM_cause);
|
||||||
|
if (present < 0)
|
||||||
|
goto exception;
|
||||||
|
if (present) {
|
||||||
|
JSValue cause = JS_GetProperty(ctx, options, JS_ATOM_cause);
|
||||||
|
if (JS_IsException(cause))
|
||||||
|
goto exception;
|
||||||
|
JS_DefinePropertyValue(ctx, obj, JS_ATOM_cause, cause,
|
||||||
|
JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (magic == JS_AGGREGATE_ERROR) {
|
if (magic == JS_AGGREGATE_ERROR) {
|
||||||
JSValue error_list = iterator_to_array(ctx, argv[0]);
|
JSValue error_list = iterator_to_array(ctx, argv[0]);
|
||||||
if (JS_IsException(error_list))
|
if (JS_IsException(error_list))
|
||||||
|
@ -102,7 +102,7 @@ default-parameters
|
|||||||
destructuring-assignment
|
destructuring-assignment
|
||||||
destructuring-binding
|
destructuring-binding
|
||||||
dynamic-import
|
dynamic-import
|
||||||
error-cause=skip
|
error-cause
|
||||||
exponentiation
|
exponentiation
|
||||||
export-star-as-namespace-from-module
|
export-star-as-namespace-from-module
|
||||||
FinalizationGroup=skip
|
FinalizationGroup=skip
|
||||||
|
Loading…
Reference in New Issue
Block a user