diff --git a/Implab.Test/AsyncTests.cs b/Implab.Test/AsyncTests.cs --- a/Implab.Test/AsyncTests.cs +++ b/Implab.Test/AsyncTests.cs @@ -139,6 +139,21 @@ namespace Implab.Test { } [TestMethod] + public void ChainFailTest() { + var p1 = new Promise(); + + var p3 = p1.Chain(x => { + var p2 = new Promise(); + p2.Reject(new Exception("DIE!!!")); + return p2; + }); + + p1.Resolve(100); + + Assert.IsTrue(p3.IsResolved); + } + + [TestMethod] public void PoolTest() { var pid = Thread.CurrentThread.ManagedThreadId; var p = AsyncPool.Invoke(() => Thread.CurrentThread.ManagedThreadId); diff --git a/Implab/Promise.cs b/Implab/Promise.cs --- a/Implab/Promise.cs +++ b/Implab/Promise.cs @@ -893,7 +893,7 @@ namespace Implab { void IPromise.On(Action success, Action error, Action cancel) { - On(x => success(), error, cancel); + On(success != null ? new Action(x => success()) : null, error, cancel); } void IPromise.On(Action success, Action error) {