hironytic / BFTaskPromise

An Objective-C category for BFTask class in Bolts-iOS
Other
11 stars 4 forks source link

The error returned by finally-block should not be ignored. #3

Closed hironytic closed 9 years ago

hironytic commented 9 years ago

The error returned from finally-block should not be ignored.

For example, Q's finally is described as:

The final handler gets called, with no arguments, when the promise returned by getInputPromise() either returns a value or throws an error. The value returned or error thrown by getInputPromise() passes directly to outputPromise unless the final handler fails, and may be delayed if the final handler returns a promise.

var outputPromise = getInputPromise()
.fin(function () {
    // close files, database connections, stop servers, conclude tests
});
  • If the handler returns a value, the value is ignored
  • If the handler throws an error, the error passes to outputPromise
  • If the handler returns a promise, outputPromise gets postponed. The eventual value or error has the same effect as an immediate return value or thrown error: a value would be ignored, an error would be forwarded.