What is the difference between throw new Error
and using Meteor.Error()
? Is it simply that throw new Error
will not be shown to the client, only on the server (the client will get a 500 Internal server error); and Meteor.Error
will be sent to the client.
Are there any more differences? Eg Does one break out of Fibers, stops downstream code?
The main thing with Meteor.Error is like you mentioned
Accounts.onLoginAttempt
) [Object object]
as the reason to be displayed from ordinary errors when they come from ordinary Errors, from Meteor.wrapAsync
Theres not much else that's different, Meteor.Error
is aa subclass of Error
with the above changes.
So they'll both stop downstream code. When it comes to Fibers, if the ordinary one is thrown out of a Fiber in any way its likely to stop your app (on the server side & not in a method
, startup
, Meteor.setInterval
, publish
, etc)
Its definition is also quite small: https://github.com/meteor/meteor/blob/devel/packages/meteor/errors.js
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.