comparison Implab/Safe.cs @ 145:706fccb85524 v2

RC: cancellation support for promises + tests
author cin
date Sun, 08 Mar 2015 02:52:27 +0300
parents 6c49d02a9a05
children 2a8466f0cb8a
comparison
equal deleted inserted replaced
144:8c0b95069066 145:706fccb85524
107 [DebuggerStepThrough] 107 [DebuggerStepThrough]
108 public static IPromise<T> InvokePromise<T>(Func<IPromise<T>> action) { 108 public static IPromise<T> InvokePromise<T>(Func<IPromise<T>> action) {
109 ArgumentNotNull(action, "action"); 109 ArgumentNotNull(action, "action");
110 110
111 try { 111 try {
112 return action() ?? Promise<T>.ExceptionToPromise(new Exception("The action returned null")); 112 return action() ?? Promise<T>.FromException(new Exception("The action returned null"));
113 } catch (Exception err) { 113 } catch (Exception err) {
114 return Promise<T>.ExceptionToPromise(err); 114 return Promise<T>.FromException(err);
115 } 115 }
116 } 116 }
117 } 117 }
118 } 118 }