2016-12-08 4 views
0

Meteorでsentry.ioを使用しようとしています。しかし、Meteorはすべてのエラーを呑み込むように見えるので、たとえ例外が手動でスローされても、このコードでは取り上げられません。Meteorの例外処理をオーバーライドします。

process.on('uncaughtException', (err) => { 
    console.log('exception') 
    console.log(err) 
}); 

私が代わりの流星にグローバルエラーハンドラを追加することができますどのような方法があり、それ自身の内部1ので、私はカスタムエラー処理コードにそれをリンクすることができますか?

答えて

0

あなたはいつでも流星の中でエラーを捕まえることができます(例えば流星の方法で)。例:

Meteor.methods({ 
    someMethod() { 
    try { 
     const result = callToSentryFunc(); 

     return result; 
    } catch (e) { 
     // e === an error object generated by sentry 
     throw new Meteor.Error('your-own-error-code', 
     'You can throw your own error that gets sent back to the client'); 
    } 
    }, 
});