New issue
Advanced search Search tips
Starred by 2 users

Issue metadata

Status: Fixed
Owner: ----
Closed: Nov 2014
HW: ----
NextAction: ----
OS: ----
Priority: ----
Type: ----

Blocking:
issue chromium:228909



Sign in to add a comment
link

Issue 2822: Messages generated from custom error events stringify as "[object Object]".

Reported by mkwst@chromium.org, Aug 2 2013 Project Member

Issue description

Copied from  crbug.com/228909 

---

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 Safari/537.31

Steps to reproduce the problem:
1. Go to this url: http://jsfiddle.net/salomvary/DVM6j/3/
2. Look at the "result" panel.

What is the expected behavior?
Should see "MyError: foo" there. 

What went wrong?
I see "Uncaught [object Object]" there.

Looks like when an error is thrown which inherits from Error, when the error is reported to window.onerror or console or developer tools, something goes wrong when creating a string representation of the error object.

Did this work before? Yes I detected the issue on the 4 Feb 2013, Chrome 25.

Chrome version: 26.0.1410.43  Channel: stable
OS Version: OS X 10.8.3

I'm not familiar with the v8/Chromium codebase but my guess is that the problem is around here:
https://code.google.com/p/chromium/codesearch#chromium/src/v8/src/messages.js&q=%22Uncaught%22%20case:yes&sq=package:chromium&type=cs&l=205
 

Comment 1 by mkwst@chromium.org, Aug 2 2013

Blocking: chromium:228909

Comment 2 by mkwst@chromium.org, Aug 2 2013

In a nutshell, it's fairly common for folks to fake inheritance via `Subclass.prototype = new Superclass();`. Handlebars does this, and it's been recommended by people who probably now know better: http://www.nczonline.net/blog/2009/03/10/the-art-of-throwing-javascript-errors-part-2/ for example.

V8 supports `subclass.prototype = Object.create(superclass.prototype);` perfectly, as well as the similar mechanism that Closure uses in 'goog.inherit' (http://docs.closure-library.googlecode.com/git/closure_goog_base.js.source.html#line1466). It falls down with this simpler sample, however.

Comment 4 by dslomov@chromium.org, Nov 4 2014

Status: Fixed

Comment 5 by dslomov@chromium.org, Nov 4 2014

Status: New

Comment 6 by dslomov@chromium.org, Nov 4 2014

Status: Fixed

Comment 7 by tkent@chromium.org, Apr 18 2016

Blocking: chromium:228909

Sign in to add a comment