New issue
Advanced search Search tips
Starred by 4 users
Status: Fixed
Owner:
Closed: Jun 2015
HW: ----
NextAction: ----
OS: ----
Priority: ----
Type: ----



Sign in to add a comment
Error.toString() throws illegal access
Reported by a...@hmlad.com, Nov 8 2012 Back to list
e = new Error();
e.type = 'foo';
e.toString();

Throws "illegal access"

 
Owner: yangguo@chromium.org
Status: Assigned
Thanks for reporting this. We are working towards resolving this.
The immediate issue has been solved, though the 'type' and 'arguments' properties should not be set for Error objects.
Comment 3 by tho...@appear.in, May 28 2015
This seems to be resolved, can it be closed?
Status: Fixed
Comment 5 by a...@goodeggs.com, Jul 29 2015
Thanks for fixing.  Could you speak a little more to "'type' and 'arguments' properties should not be set for Error objects"?  It doesn't seem to be widely known in the javascript community.  Several library authors have used 'type' before this issue surfaced:

https://github.com/TryGhost/Ghost/issues/5178
https://github.com/Automattic/mongoose/issues/1323

And there's no mention of these properties being special on MDN:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error

Should I be discouraging folks from using 'type', or is safe with this fix?  
"type" and "arguments" were special properties used internally by V8. That was a bug that has been fixed. They are no longer used internally so it should be fine to set and use them on Error objects.
Comment 7 by a...@goodeggs.com, Jul 30 2015
Good to know, thanks!
Sign in to add a comment