Mercurial > pub > ImplabNet
comparison Implab/Safe.cs @ 133:6c49d02a9a05 v2
sync
author | cin |
---|---|
date | Mon, 09 Feb 2015 00:28:13 +0300 |
parents | 5fb2bbffdece |
children | 706fccb85524 |
comparison
equal
deleted
inserted
replaced
132:5fb2bbffdece | 133:6c49d02a9a05 |
---|---|
87 | 87 |
88 [DebuggerStepThrough] | 88 [DebuggerStepThrough] |
89 public static IPromise InvokePromise(Func<IPromise> action) { | 89 public static IPromise InvokePromise(Func<IPromise> action) { |
90 ArgumentNotNull(action, "action"); | 90 ArgumentNotNull(action, "action"); |
91 | 91 |
92 var p = new Promise(); | |
93 try { | 92 try { |
94 action(); | 93 var p = action(); |
95 p.Resolve(); | 94 if (p == null) { |
95 var d = new Promise(); | |
96 d.Reject(new Exception("The action returned null")); | |
97 p = d; | |
98 } | |
99 return p; | |
96 } catch (Exception err) { | 100 } catch (Exception err) { |
101 var p = new Promise(); | |
97 p.Reject(err); | 102 p.Reject(err); |
103 return p; | |
98 } | 104 } |
99 | |
100 return p; | |
101 } | 105 } |
102 | 106 |
103 [DebuggerStepThrough] | 107 [DebuggerStepThrough] |
104 public static IPromise<T> InvokePromise<T>(Func<IPromise<T>> action) { | 108 public static IPromise<T> InvokePromise<T>(Func<IPromise<T>> action) { |
105 ArgumentNotNull(action, "action"); | 109 ArgumentNotNull(action, "action"); |