gpt4 book ai didi

meteor - 在 Meteor 中,this.error 和在 Meteor.publish 中抛出新的 Meteor.Error 有什么区别?

转载 作者:行者123 更新时间:2023-12-04 17:36:58 25 4
gpt4 key购买 nike

Meteor.publish ,使用 this.error 有什么区别并简单地抛出 Meteor.Error ?

最佳答案

this.error仅在发布方法内可用。每 the docs :

Stops this client's subscription, triggering a call on the client to the onError callback passed to Meteor.subscribe, if any. If error is not a Meteor.Error, it will be mapped to Meteor.Error(500, "Internal server error").



throw Meteor.Error不会停止客户端的订阅,它只会终止执行并引发异常。因此,如果您想确保 Meteor 会在您之后进行清理并允许您在发生意外情况时处理客户端上的错误,建议使用 this.error而不是在发布方法中扔你自己的。

关于meteor - 在 Meteor 中,this.error 和在 Meteor.publish 中抛出新的 Meteor.Error 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15511497/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com