Skip to content

Instantly share code, notes, and snippets.

@marshall007
Forked from heath/q_play.coffee
Last active January 4, 2016 04:59
Show Gist options
  • Save marshall007/8572107 to your computer and use it in GitHub Desktop.
Save marshall007/8572107 to your computer and use it in GitHub Desktop.
WILL_REJECT = true
a = ->
foo = q.defer()
if WILL_REJECT
foo.reject()
else
foo.resolve()
return foo.promise
b = a.catch (e) ->
return e
b.then (c) ->
# continue along, no
# need for moar promises
var WILL_REJECT, a, b;
WILL_REJECT = true;
a = function() {
var foo;
foo = q.defer();
if (WILL_REJECT) {
foo.reject();
} else {
foo.resolve();
}
return foo.promise;
};
b = a["catch"](function(e) {
return e;
});
b.then(function(c) {
});
@heath
Copy link

heath commented Jan 23, 2014

TypeError: Object function () {
var foo;
foo = q.defer();
if (WILL_REJECT) {
foo.reject();
} else {
foo.resolve();
}
return foo.promise;
} has no method 'catch'
at Object. (/Users/heath/ptest.coffee:12:14, :17:17)
at Object. (/Users/heath/ptest.coffee:1:1, :23:4)
at Module._compile (module.js:456:26)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment