Skip to content
This repository was archived by the owner on Jan 21, 2024. It is now read-only.
This repository was archived by the owner on Jan 21, 2024. It is now read-only.

Utilize .toString hack to get Error during window.onerror #55

@JamesMGreene

Description

@JamesMGreene

I came up with a clever technique a few months ago that I wanted to try out... turns out to be a win but only in Firefox (so far as I've seen):
    http://jsfiddle.net/JamesMGreene/MYgpY/

Basically you override the Error.prototype.toString method to store a reference to that Error so that you can access it again during the window.onerror handler even if the 5th error argument does not exist. This works on the notion that the browsers would invoke the toString (or valueOf) method when getting the string to pass as the 1st message argument to window.onerror; however, it turns out that this assumption is only currently valid in Firefox (as far as major browsers go, anyway)... the others seem to utilize some internal conversion approach instead. Either way, it's easy to feature test and can be a big win in Firefox.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions