diff --git a/packages/ddp-client/livedata_connection.js b/packages/ddp-client/livedata_connection.js index b59e486608..c3783fbfd0 100644 --- a/packages/ddp-client/livedata_connection.js +++ b/packages/ddp-client/livedata_connection.js @@ -823,13 +823,18 @@ _.extend(Connection.prototype, { // If an exception occurred in a stub, and we're ignoring it // because we're doing an RPC and want to use what the server - // returns instead, log it so the developer knows. + // returns instead, log it so the developer knows + // (unless they explicitly ask to see the error). // // Tests can set the 'expected' flag on an exception so it won't // go to log. - if (exception && !exception.expected) { - Meteor._debug("Exception while simulating the effect of invoking '" + - name + "'", exception, exception.stack); + if (exception) { + if (options.throwStubExceptions) { + throw exception; + } else if (!exception.expected) { + Meteor._debug("Exception while simulating the effect of invoking '" + + name + "'", exception, exception.stack); + } } diff --git a/packages/ddp-client/livedata_tests.js b/packages/ddp-client/livedata_tests.js index 2cf1373875..8b3e72d284 100644 --- a/packages/ddp-client/livedata_tests.js +++ b/packages/ddp-client/livedata_tests.js @@ -193,6 +193,19 @@ testAsyncMulti("livedata - basic method invocation", [ test.equal(Meteor.call("exception", "both"), undefined); test.equal(Meteor.call("exception", "server"), undefined); test.equal(Meteor.call("exception", "client"), undefined); + + // If we pass throwStubExceptions then we *should* see thrown exceptions + // on the client + test.throws(function () { + Meteor.apply("exception", ["both"], {throwStubExceptions: true}); + }); + test.equal( + Meteor.apply("exception", ["server"], {throwStubExceptions: true}), + undefined); + test.throws(function () { + Meteor.apply("exception", ["client"], {throwStubExceptions: true}); + }); + } // With callback