Skip to content

Unhandled exceptions aren't logged automatically #54

@PhilippSoehnlein

Description

@PhilippSoehnlein

The Readme claims:

Once configured, Exceptionless.js will automatically submit any unhandled exceptions that happen in your application to the Exceptionless server.

For me it looks like this isn't the case. Here's a reduced test case in which I would expect to get three exceptions logged to the server, which doesn't happen:

<!DOCTYPE html>

<html>
<head>
    <title>Exceptionless test</title>
    <script src="https://raw.githubusercontent.com/exceptionless/Exceptionless.JavaScript/master/dist/exceptionless.js"></script>
    <script>
        var exceptionlessClient = new exceptionless.ExceptionlessClient( {
            apiKey: 'YOUR_API_KEY',
            serverUrl: 'YOUR_SERVER',
        } );
  </script>
</head>

<body>
    <button type="button">Throw exception, plz.</button>

    <script>
        // This isn't reported to the Exceptionless server:
        window.setTimeout(
            function() { throw new Error( 'Test error in setTimeout handler' ); },
            1000
        );

        // This isn't either:
        document.getElementsByTagName( 'button' )[0].addEventListener(
            'click',
            function() { throw new Error( 'Test error in click handler' ); },
            false
        );

        // No report, again…
        (function xhrExceptionTest() {
            var myRequest = new XMLHttpRequest();
            myRequest.open( 'GET', 'http://httpstat.us/500', true );
            myRequest.onreadystatechange = function() {
                if ( myRequest.readyState === myRequest.DONE && myRequest.status !== 200 ) {
                    throw new Error( 'Test error in XHR handler' );
                }
            };
            myRequest.send( null );
        }());

        // This works:
        // exceptionlessClient.submitException( new Error( 'submitException' ) );
    </script>
</body>
</html>

I tested with Firefox 46, Chrome 50 and Safari 9.1 on Mac OS 10.11.4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions