/// <summary> /// Subscribe to event with special behavior when handler failed. If it fails with TException - onFail is called /// </summary> public static Delegate <TEvent> AddOnFail <TEvent, TException>(this Delegate <TEvent> handler, FailDelegate <TEvent> onFailHandler, OnException.DelegateInterface onException = null) where TException : Exception { return((param) => { try { handler(param); } catch (TException ex) { onFailHandler(param, ex); onException?.Invoke(ex); } }); }
/// <summary> /// Subscribe to event with special behavior when handler failed. If it fails with TException - onFail is called /// </summary> public static Delegate <TEvent> AddOnFail <TEvent, TException>(this ICanHandle <TEvent> handler, FailDelegate <TEvent> onFailHandler, OnException.DelegateInterface onException = null) where TException : Exception { return(AddOnFail <TEvent, TException>(handler.Handle, onFailHandler, onException)); }