-
Notifications
You must be signed in to change notification settings - Fork 9
Consider having cause always present #35
Comments
It's interesting to compare this issue with how However, |
( |
Ah, yep, substitute +1 on not having |
Clarification: Are you proposing that |
I don't have a strong preference on non-constructor-created error instances, since my strongest preference is for Having it be on all instances would be nicer for the cloning and shape-shifting object complaints, so I think it would be slightly better. But as noted above |
I think all host-created error instances have a |
Like said in the thread, it will be quite awkward if we can not distinguish if a cause is present or not. IIUC, the problem here is that the error objects are not "fixed" shapes in various constructing patterns. As mentioned in the thread, the "message" property is already not in "fixed" shapes. One alternative to the problem could be adding another boolean field |
Closing as the proposal has reached consensus to stage 4. |
The spec right now tries to use the existence of cause in the options bag to decide if cause should be present on the Error object.
This seems a bit weird, as we try in most parts of the language (and also the web platform) not to distinguish between "not present" and "present but undefined".
It also leads to annoying questions like, if I'm cloning an error, do I need to check for cause's presence? It'd be nicer if I could just do
clone.cause = original.cause
or, if I'm feeling fancy,Object.defineProperty(clone, "cause", Object.getOwnPropertyDescriptor(original, "cause"))
.Finally, these sort of sometimes-one-shape-sometimes-another objects are pretty unusual for the ECMAScript spec. Although Errors are pretty unusual for the ECMAScript spec already, I think this extra bit of weirdness isn't necessary.
The text was updated successfully, but these errors were encountered: