RESOLVED FIXED 223302
[JSC] Implement Error#cause
https://bugs.webkit.org/show_bug.cgi?id=223302
Summary [JSC] Implement Error#cause
Ross Kirsling
Reported 2021-03-16 20:15:34 PDT
[JSC] Implement Error#cause
Attachments
Patch (34.88 KB, patch)
2021-03-16 20:29 PDT, Ross Kirsling
no flags
Patch (35.02 KB, patch)
2021-03-16 20:58 PDT, Ross Kirsling
no flags
Patch for landing (34.88 KB, patch)
2021-03-16 22:17 PDT, Ross Kirsling
no flags
Ross Kirsling
Comment 1 2021-03-16 20:29:22 PDT
Ross Kirsling
Comment 2 2021-03-16 20:33:36 PDT
Comment on attachment 423427 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=423427&action=review > Source/JavaScriptCore/API/JSObjectRef.cpp:236 > JSValue message = argumentCount ? toJS(globalObject, arguments[0]) : jsUndefined(); > + JSValue options = argumentCount > 1 ? toJS(globalObject, arguments[1]) : jsUndefined(); > Structure* errorStructure = globalObject->errorStructure(); > - JSObject* result = ErrorInstance::create(globalObject, errorStructure, message); > + JSObject* result = ErrorInstance::create(globalObject, errorStructure, message, options); Note: We don't need to add support to JSObjectMakeError, but it's literally no extra effort to do so.
Yusuke Suzuki
Comment 3 2021-03-16 20:39:45 PDT
Comment on attachment 423427 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=423427&action=review r=me > JSTests/stress/error-cause.js:6 > +const errorConstructors = [Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError, AggregateError]; Can we add WebAssembly Errors if `typeof WebAssembly !== "undefined"`?
Ross Kirsling
Comment 4 2021-03-16 20:58:58 PDT
Ross Kirsling
Comment 5 2021-03-16 22:05:37 PDT
(In reply to Yusuke Suzuki from comment #3) > > JSTests/stress/error-cause.js:6 > > +const errorConstructors = [Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError, AggregateError]; > > Can we add WebAssembly Errors if `typeof WebAssembly !== "undefined"`? Oops, we actually don't want to test these; their behavior hasn't changed (since they're not part of ECMA-262), it's just that they depend on ErrorInstance, whose interface changed.
EWS
Comment 6 2021-03-16 22:07:24 PDT Comment hidden (obsolete)
Ross Kirsling
Comment 7 2021-03-16 22:17:21 PDT
Created attachment 423435 [details] Patch for landing
EWS
Comment 8 2021-03-16 23:02:47 PDT
Committed r274552: <https://commits.webkit.org/r274552> All reviewed patches have been landed. Closing bug and clearing flags on attachment 423435 [details].
Radar WebKit Bug Importer
Comment 9 2021-03-16 23:03:15 PDT
Keith Miller
Comment 10 2021-03-17 12:31:01 PDT
Comment on attachment 423435 [details] Patch for landing This should probably be behind a JSC flag (it can be on by default though) since it's technically a feature, albeit a simple one.
Devin Rousso
Comment 11 2021-03-17 13:00:17 PDT
Out of curiosity what does this look like in Web Inspector? Should it have special treatment there given that one of the motivations for this feature was for developer tooling/debugging/etc.?
Ross Kirsling
Comment 12 2021-03-17 16:37:51 PDT
(In reply to Keith Miller from comment #10) > Comment on attachment 423435 [details] > Patch for landing > > This should probably be behind a JSC flag (it can be on by default though) > since it's technically a feature, albeit a simple one. Alright, I can add that to the WASM-related follow-up patch. (In reply to Devin Rousso from comment #11) > Out of curiosity what does this look like in Web Inspector? Should it have > special treatment there given that one of the motivations for this feature > was for developer tooling/debugging/etc.? It should look the same as before for now. It would make sense to have a helpful display for this information, though of course it's possible to use this information for non-debugging purposes too -- to give better error messages, to do different things based on the first error in the cascade, etc.
Note You need to log in before you can comment on or make changes to this bug.