Raven.js: breaks `window.onerror`


I tried to integrate raven.js with my JavaScript application.

I raise an exception somewhere in the middle of my code:

throw new Error("Test sentry");


doSomething(); // doSomething does not exist

I have my own window.onerror handler. If raven.js is not enabled, it works perfectly fine. When I enable raven.js it does not provide any useful information about error:

// raven.js is enabled
window.onerror = function(msg, url, lineNo, columnNo, error) {
        // msg is always `Script error`
        // lineNo and columnNo is always 0
        // error is null
        return false;

Are you sure this is raven.js related? “Script Error” you usually get because of cross domain issues.

Thank you for reply.

Are you sure this is raven.js related?

Yes. I’m sure. Because before adding raven.js into a browser it worked perfectly fine.
I think raven.js re-raises an exception from different domain or something like that.

May be it should provide some mechanism to avoid it or some callback ability to catch original exception.

looks like I found a solution, based on

I added raven.js using following way:

<script src="https://cdn.ravenjs.com/3.7.0/raven.min.js" crossorigin="anonymous"></script>

Not sure why it is not default recommended way.

Thank you for your help.

That is a valid remark. We will fix this.