Skip Menu |

This queue is for tickets about the Promises CPAN distribution.

Report information
The Basics
Id: 81356
Status: resolved
Priority: 0/
Queue: Promises

People
Owner: Nobody in particular
Requestors: TOSHIOITO [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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().
Error callbacks are now optional and will bubble through the chain correctly, thanks for this suggestion. The code is currently on github (https://github.com/stevan/promises-perl) but will be released to CPAN as 0.02 shortly.
sorry, forgot to resolve