comparison Implab/Promise.cs @ 99:8ddf1648eca4 v2

fixed TransientPromiseException handling
author cin
date Wed, 05 Nov 2014 02:31:35 +0300
parents daffa72a1cec
children 279e226dffdd
comparison
equal deleted inserted replaced
98:4c945d94b9ab 99:8ddf1648eca4
71 if (errorHandler != null) { 71 if (errorHandler != null) {
72 try { 72 try {
73 var res = errorHandler(err); 73 var res = errorHandler(err);
74 if (medium != null) 74 if (medium != null)
75 medium.Resolve(res); 75 medium.Resolve(res);
76 } catch (TransientPromiseException err2) { 76 /*} catch (TransientPromiseException err2) {
77 if (medium != null) 77 if (medium != null)
78 medium.Reject(err2.InnerException); 78 medium.Reject(err2.InnerException);*/
79 } catch (Exception err2) { 79 } catch (Exception err2) {
80 if (medium != null) 80 if (medium != null)
81 medium.Reject(err2); 81 medium.Reject(err2);
82 } 82 }
83 } else if (medium != null) 83 } else if (medium != null)
201 /// </remarks> 201 /// </remarks>
202 /// <param name="error">Исключение возникшее при выполнении операции</param> 202 /// <param name="error">Исключение возникшее при выполнении операции</param>
203 /// <exception cref="InvalidOperationException">Данное обещание уже выполнено</exception> 203 /// <exception cref="InvalidOperationException">Данное обещание уже выполнено</exception>
204 public void Reject(Exception error) { 204 public void Reject(Exception error) {
205 if (BeginTransit()) { 205 if (BeginTransit()) {
206 m_error = error; 206 m_error = error is TransientPromiseException ? error.InnerException : error;
207 CompleteTransit(REJECTED_STATE); 207 CompleteTransit(REJECTED_STATE);
208 OnStateChanged(); 208 OnStateChanged();
209 } else { 209 } else {
210 WaitTransition(); 210 WaitTransition();
211 if (m_state == SUCCEEDED_STATE) 211 if (m_state == SUCCEEDED_STATE)