Skip to content

Commit

Permalink
Catch only exceptions thrown by model[func]() (fix canjs#454 and re c…
Browse files Browse the repository at this point in the history
…anjs#384)

The Deferred is resolved only if model[func]() succeeds.
  • Loading branch information
scorphus committed Jul 27, 2013
1 parent 1a46211 commit 54b1c3f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ steal('can/util','can/observe', function( can ) {
var pipe = function( def, model, func ) {
var d = new can.Deferred();
def.then(function(){
var args = can.makeArray( arguments );
var args = can.makeArray( arguments ),
success = true;
try {
args[0] = model[func](args[0]);
d.resolveWith(d, args);
} catch(e) {
success = false;
d.rejectWith(d, [e].concat(args));
}
if (success) {
d.resolveWith(d, args);
}
},function(){
d.rejectWith(this, arguments);
});
Expand Down

0 comments on commit 54b1c3f

Please sign in to comment.