mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Added throwStubExceptions option to Meteor.call
Allows method simulations to be used as validators and enables freely throwing exceptions in method definitions without worrying about spurious logging on the client.
This commit is contained in:
committed by
David Glasser
parent
5a512ea990
commit
d758441cf4
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user