-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error object property "name" should be writable #144
Comments
It seems to me that this is due to xs/sources/xsError.c setting I set this to I also still cannot set the EDIT: Am I confused? I can't see why a EDIT²: Now I'm really confused. In my project code I think
No write protection, no special object. MDN even has this example "Throwing a custom error": var e = new Error('Malformed input'); // e.name is 'Error'
e.name = 'ParseError';
throw e;
// e.toString() would return 'ParseError: Malformed input' |
This comment has been minimized.
This comment has been minimized.
This is a consequence of freezing of the |
I already know you are freezing prototypes. However, the way this works and is supposed to work, looking at other runtimes, is that a new property in the instance is created. If the measure you took prevent adding an instance property this is not just "freezing the prototype". |
I read the link again, I had already read it some time ago, just to be sure I did not misread. The example there explicitly directly changes the prototype object. This has nothing to do with this issue here. Assigning to |
It is a consequence of |
Okay, they indeed do. TIL. |
Interesting that Object.defineProperty() still works. |
I give
Error
objects names (i.e. settingname
property, sometimes replacing an existingmessage
property too) because I prefer this over sub-classing Errors, which only is simple on ES 2015 and with a functional style I don't have a single "class", "this", "bind" in any of my code, it's "just functions".This is perfectly legal JS. It should just be a normal object.
Code
Result
Error:
set name: not writable!
The text was updated successfully, but these errors were encountered: