comparison Implab/AbstractPromiseT.cs @ 197:86187b01c4e0

fixed: the error handler should not handle handlers errors
author cin
date Thu, 01 Sep 2016 10:43:31 +0300
parents 97fbbf816844
children cbe10ac0731e
comparison
equal deleted inserted replaced
196:40d7fed4a09e 197:86187b01c4e0
37 37
38 public void SignalSuccess(T result) { 38 public void SignalSuccess(T result) {
39 if (m_success != null) { 39 if (m_success != null) {
40 try { 40 try {
41 m_success(result); 41 m_success(result);
42 } catch(Exception err) { 42 // Analysis disable once EmptyGeneralCatchClause
43 SignalError(err); 43 } catch {
44 } 44 }
45 } else if ((m_mask & PromiseEventType.Success) != 0 && m_handler != null) { 45 } else if ((m_mask & PromiseEventType.Success) != 0 && m_handler != null) {
46 try { 46 try {
47 m_handler(); 47 m_handler();
48 } catch(Exception err) { 48 // Analysis disable once EmptyGeneralCatchClause
49 // avoid calling handler twice in case of error 49 } catch {
50 if (m_error != null)
51 SignalError(err);
52 } 50 }
53 } 51 }
54 } 52 }
55 53
56 public void SignalError(Exception err) { 54 public void SignalError(Exception err) {
71 69
72 public void SignalCancel(Exception reason) { 70 public void SignalCancel(Exception reason) {
73 if (m_cancel != null) { 71 if (m_cancel != null) {
74 try { 72 try {
75 m_cancel(reason); 73 m_cancel(reason);
76 } catch (Exception err) { 74 // Analysis disable once EmptyGeneralCatchClause
77 SignalError(err); 75 } catch {
78 } 76 }
79 } else if ((m_mask & PromiseEventType.Cancelled) != 0 && m_handler != null) { 77 } else if ((m_mask & PromiseEventType.Cancelled) != 0 && m_handler != null) {
80 try { 78 try {
81 m_handler(); 79 m_handler();
82 // Analysis disable once EmptyGeneralCatchClause 80 // Analysis disable once EmptyGeneralCatchClause