Mercurial > pub > ImplabNet
diff Implab/Safe.cs @ 133:6c49d02a9a05 v2
sync
author | cin |
---|---|
date | Mon, 09 Feb 2015 00:28:13 +0300 |
parents | 5fb2bbffdece |
children | 706fccb85524 |
line wrap: on
line diff
--- a/Implab/Safe.cs Sat Feb 07 19:41:31 2015 +0300 +++ b/Implab/Safe.cs Mon Feb 09 00:28:13 2015 +0300 @@ -89,15 +89,19 @@ public static IPromise InvokePromise(Func<IPromise> action) { ArgumentNotNull(action, "action"); - var p = new Promise(); try { - action(); - p.Resolve(); + var p = action(); + if (p == null) { + var d = new Promise(); + d.Reject(new Exception("The action returned null")); + p = d; + } + return p; } catch (Exception err) { + var p = new Promise(); p.Reject(err); + return p; } - - return p; } [DebuggerStepThrough]