Errors not being thrown?

22 views
Skip to first unread message

m b

unread,
Jul 9, 2016, 6:51:22 PM7/9/16
to DurandalJS

I have a durandal app being built with gulp. In production, I see this in logs (not as an exception):

ERROR: Cannot read property 'go' of undefined TypeError: Cannot read property 'go' of undefined(…)

I am throwing this error on purpose because I want to actually throw an error, this way I can track all clientside exceptions with the following:

window.onerror = function errorHandler(msg, url, line, col, obj) {
    var errorUser = "User: " + app.username();
    var errorUrl = "Url: " + url;
    var errorMessage = "   Message: " + msg;
    var errorLine = "   Line: " + line;
    var errorCol = "     Col: " + col;
    var errorObj = "     Obj: " + obj;
    var errorRoute = "Route: ";
    var instruction = router.activeInstruction();
    if (instruction != null) {
        errorRoute += instruction.fragment + ", ";
        errorRoute += instruction.queryString + ", ";
        errorRoute += instruction.params.toString() + ", ";
    }

    messageService.raiseError(errorUser + errorUrl + errorMessage + errorLine + errorCol + errorObj + errorRoute);
    // Just let default handler run.
    return false;
};

But even with the following in main.js, that ERROR is being swallowed up:

system.debug(true);
binder.throwOnErrors = true;

How can I catch/log ALL clientside errors here?

FYI my error is being thrown here:

vm.activate = function () {
    // intentional error
    vm.test.test = vm.go.go;
};
Reply all
Reply to author
Forward
0 new messages