Meteor.call
サーバーコードでエラーが内部で発生した場合、クライアントのエラーコールバックでエラーを取得できませんMeteor.bindEnvironment
。以下は複製するサンプルコードです
サーバー内
Meteor.methods({
customMethod: function(arg1, arg2){
Stripe.customers.create({
email: "email@here.com,
description: "blah blah",
source: token,
metadata: {
planId: planId,
quantity: n
},
plan: planId,
quantity: n
}, Meteor.bindEnvironment(function (err, customer) {
if(err){
console.log("error", err);
// TODO cannot catch this error on the client
throw new Meteor.Error(err.rawType, err.message)
}
}))
}
})
Meteor イベント内のクライアントでは、
Meteor.call('customMethod', arg1, arg2, function (err, resp) {
if(err){
Session.set('some-error', err)
}
if(resp){
// TODO cannot catch errors throwing from the server
// when inside Meteor.bindEnvironment
Session.set('some-success', true)
}
});
セッション変数が設定されることはありません。どんな助けでも素晴らしいでしょう。ありがとう!