How to handle all errors in one place?


#1

I am gettin pretty tired of catching and handling errors in every method call:

Meteor.call('something', err => if(err) snackBar(err.reason)

Can i just write something like this?:

window.onerror = function (errorMsg) {
    snackBar(errorMsg)
}

Problem is this code does not work. When i throw this kind of errors:

throw new Meteor.Error('not-authorized')

nothing is happenning.