Mercurial > pub > ImplabNet
comparison Implab/SuccessPromise.cs @ 203:4d9830a9bbb8 v2
Added 'Fail' method to RunnableComponent which allows component to move from
Running to Failed state.
Added PollingComponent a timer based runnable component
More tests
Added FailPromise a thin class to wrap exceptions
Fixed error handling in SuccessPromise classes.
| author | cin | 
|---|---|
| date | Tue, 18 Oct 2016 17:49:54 +0300 | 
| parents | 706fccb85524 | 
| children | cbe10ac0731e | 
   comparison
  equal
  deleted
  inserted
  replaced
| 202:2651cb9a4250 | 203:4d9830a9bbb8 | 
|---|---|
| 6 | 6 | 
| 7 public IPromise On(Action success, Action<Exception> error, Action<Exception> cancel) { | 7 public IPromise On(Action success, Action<Exception> error, Action<Exception> cancel) { | 
| 8 if (success != null) { | 8 if (success != null) { | 
| 9 try { | 9 try { | 
| 10 success(); | 10 success(); | 
| 11 } catch(Exception err) { | 11 // Analysis disable once EmptyGeneralCatchClause | 
| 12 if (error != null) { | 12 } catch { | 
| 13 try { | |
| 14 error(err); | |
| 15 // Analysis disable once EmptyGeneralCatchClause | |
| 16 } catch { | |
| 17 } | |
| 18 } | |
| 19 } | 13 } | 
| 20 } | 14 } | 
| 21 return this; | 15 return this; | 
| 22 } | 16 } | 
| 23 | 17 | 
| 24 public IPromise On(Action success, Action<Exception> error) { | 18 public IPromise On(Action success, Action<Exception> error) { | 
| 25 if (success != null) { | 19 if (success != null) { | 
| 26 try { | 20 try { | 
| 27 success(); | 21 success(); | 
| 28 } catch(Exception err) { | 22 // Analysis disable once EmptyGeneralCatchClause | 
| 29 if (error != null) { | 23 } catch { | 
| 30 try { | |
| 31 error(err); | |
| 32 // Analysis disable once EmptyGeneralCatchClause | |
| 33 } catch { | |
| 34 } | |
| 35 } | |
| 36 } | 24 } | 
| 37 } | 25 } | 
| 38 return this; | 26 return this; | 
| 39 } | 27 } | 
| 40 | 28 | 
