Subject: | errorback in then() should be optional |
I'm not sure what specification you refer to, but CommonJS Promises/A
spec(*1) says that all arguments for then() method are optional and
non-function values are ignored.
(*1) http://wiki.commonjs.org/wiki/Promises/A
I don't see any reason to omit the fulfilledHandler ($callback), but
it would be handy if we can omit the errorHandler ($error). This is
like we are not catching any exception.
## operation1() and operation2() both return a Promise
operation1()->then(sub {
my $result = shift;
return operation2($result);
})->then(sub {
my $result = shift;
say "operation1 and operation2 succeeded! result = $result";
}, sub {
my $error = shift;
say "This catches an exception from operation1 and operation2";
});
In the above example, an error from operation1 and operation2 bubbles
up to the error handler in the second then().
I think we can bubble up the results by passing sub { @_ } to then()
method, but I'm not sure if it's a good idea to write that for every
call to then().