Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

catching errors inside hooks for logging to papertrail #187

Open
WayneUong opened this issue May 4, 2016 · 2 comments
Open

catching errors inside hooks for logging to papertrail #187

WayneUong opened this issue May 4, 2016 · 2 comments

Comments

@WayneUong
Copy link

WayneUong commented May 4, 2016

How do I catch exceptions? This code does not print out an error, where it should throw an exception as b is undefined.

Projects.after.insert(function (userId, doc) {
    try {
        a = b.c
    } catch (err) {
        console.log(err);
    }
});

@lawrentiy
Copy link

The best way - to realize catching into the package itself.
Ive done so behavior in the fork and it saves my mind is case of chains of hooks. I dont know, why authors don`t implement it in package, m.b. because of optimization...

Or, do you call that code on server or client?

@zimme
Copy link
Member

zimme commented May 16, 2017

Wrap Projects.insert calls with try/catch and I believe that would catch errors throw inside its hooks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants