Meteor.Error will not be encoded in EJSON. We are relying on how it encodes as

EJSON already. Make this clear.
This commit is contained in:
David Glasser
2013-02-05 16:34:42 -08:00
parent 0077bbbb65
commit 25fa54cbae
6 changed files with 10 additions and 4 deletions

View File

@@ -109,6 +109,11 @@ Meteor._stringifyDDP = function (msg) {
Meteor._CurrentInvocation = new Meteor.EnvironmentVariable;
// Note: The DDP server assumes that Meteor.Error EJSON-serializes as an object
// containing 'error' and optionally 'reason' and 'details'.
// The DDP client manually puts these into Meteor.Error objects. (We don't use
// EJSON.addType here because the type is determined by location in the
// protocol, not text on the wire.)
Meteor.Error = function (error, reason, details) {
var self = this;

View File

@@ -1191,7 +1191,6 @@ _.extend(Meteor._LivedataConnection.prototype, {
currentMethodBlock.splice(i, 1);
if (_.has(msg, 'error')) {
// XXX should we hook Meteor.Error in to EJSON?
m.receiveResult(new Meteor.Error(
msg.error.error, msg.error.reason,
msg.error.details));

View File

@@ -1418,7 +1418,7 @@ Tinytest.add("livedata stub - subscribe failure", function (test) {
// Reject the sub.
stream.receive({msg: 'nosub', id: subMessage.id,
error: {error: 404, reason: "Subscription not found"}});
error: new Meteor.Error(404, "Subscription not found")});
test.isFalse(onReadyFired);
test.instanceOf(subError, Meteor.Error);
test.equal(subError.error, 404);

View File

@@ -569,7 +569,7 @@ _.extend(Meteor._LivedataSession.prototype, {
if (!handler) {
self.send({
msg: 'result', id: msg.id,
error: {error: 404, reason: "Method not found"}});
error: new Meteor.Error(404, "Method not found")});
fence.arm();
return;
}

View File

@@ -6,6 +6,8 @@ Package.describe({
Package.on_use(function (api, where) {
where = where || ["client", "server"];
api.use('ejson');
// XXX These files have various dependencies on other packages
// that aren't specified here. :(
// This package should probably get split into several packages,

View File

@@ -36,7 +36,7 @@ _.extend(Meteor._StubStream.prototype, {
var self = this;
if (typeof data === 'object') {
data = JSON.stringify(data);
data = EJSON.stringify(data);
}
_.each(self.callbacks['message'], function (cb) {