Promises Programming Pattern Verification

Attached [CryptoPromises.sample.txt] is a sample of my understanding of how WebCrypto Promises will be used.  Generically speaking, there seem to be two possible Promises programming patterns Example1 vs. Example2.  I believe Example1 captures the programming pattern we are proposing: (using arrows to show indentation):

EXAMPLE1 (does this imply single operations):
CryptoPromise1.then(...
-->CryptoPromise2.then(...
----->CryptoPromise3.then(...)
-->),
-->failureFunctionPromise1(...)
);

vs. 

EXAMPLE2 (is this needed for multi-part operations)?
CryptoPromise1.then(...,failureFunctionPromise1(...)).then(...).then(...);

Can we validate that EXAMPLE1 and not EXAMPLE2 is the expected pattern and that this model will not support multi-part on the first release of the spec.

Also, per our previous conversation (a couple of weeks back) the expected error handling is ideally exception free and relies on the promise failure handler model (EXAMPLE1).  In this model, all error handling can be done inside the failureFunctionPromise1() function vs. the exception based pattern outlined in EXAMPLE3 which breaks the error handling into two blocks (exceptions vs. failed promises):

EXAMPLE3:
try {
->CryptoPromise1.then(...
-->CryptoPromise2.then(...
----->CryptoPromise3.then(...)
-->),
-->failureFunctionPromise1(
---->// handle promises failures
-->)
->);
} catch(e) {
-->//handle exception failures
}

Thanks,

Israel

Received on Tuesday, 12 November 2013 03:48:09 UTC