Skip to content

Commit

Permalink
fix(fastq): adds missing 'catch' method to promises
Browse files Browse the repository at this point in the history
Fixes #183
  • Loading branch information
iobaixas committed Jan 7, 2015
1 parent 420f9dd commit 1fea426
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/module/fastq.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
*/
RMModule.factory('RMFastQ', [function() {

var isFunction = angular.isFunction;
var isFunction = angular.isFunction,
catchError = function(_error) {
return this.then(null, _error);
};

function simpleQ(_val, _withError) {

Expand All @@ -22,6 +25,7 @@ RMModule.factory('RMFastQ', [function() {
then: function(_success, _error) {
return simpleQ(_withError ? _error(_val) : _success(_val));
},
'catch': catchError,
'finally': function(_cb) {
var result = _cb();
if(result && isFunction(_val.then)) {
Expand Down Expand Up @@ -55,6 +59,7 @@ RMModule.factory('RMFastQ', [function() {
simple.then(_success, _error) :
wrappedQ(_promise.then(_success, _error));
},
'catch': catchError,
'finally': function(_cb) {
return simple ?
simple['finally'](_cb) :
Expand Down

0 comments on commit 1fea426

Please sign in to comment.