I know, that there is a lot of discussions about this topic. But instead of it, I still did not found the solution. Therefore I would like to kindky ask, how to reliably catch all errors on client side?
I tested Sentry and also Meteor-Logger, but the problems seems to be the same:
Probably, both of the solution are trying to catch errors with the following way:
/* Store original window.onerror */
const _GlobalErrorHandler = window.onerror;
window.onerror = function (msg, url, line) {
log.error(msg, {file: url, onLine: line});
if (_GlobalErrorHandler) {
_GlobalErrorHandler.apply(this, arguments);
}
};
But If I will try to make a mistake for example in Blaze, the Blaze render method in FlowRouter is async and Meteor-Logger and also Sentry does not catch this error.
Blaze template:
Template.projects.onRendered(() => {
foooo();
});
Router:
loggedRoutes.route('/', {
name: 'home',
action: function () {
this.render('layout', 'projects');
},
waitOn() {
return [
import('./views/projects/projects_script'),
Meteor.subscribe('projects_published_list')
];
}
});
Browser console
ReferenceError: foooo is not defined
at Blaze.TemplateInstance.eval (projects_script.js:16)
at template.js:119
...
...
...
How can I catch all errors on client side?
Note:
If I will be able to catch errors from Router (from importing and rendering the Blaze templates), I will take under control biggerst part of Meteor client side (I think).
Thanks a lot for each idea.