Last active
November 6, 2015 22:11
-
-
Save cartermp/84d78268130e02aa6251 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace YES | |
{ | |
public abstract class ErrorReportingBase | |
{ | |
public ErrorReportingBase(ErrorOccurredHandler handler) | |
{ | |
this.ErrorOccurred += handler; | |
} | |
public event ErrorOccurredHandler ErrorOccurred; | |
public delegate void ErrorOccurredHandler(Exception ex); | |
/// <summary> | |
/// Raises the error so that it can be handled by the controlling class. | |
/// </summary> | |
/// <param name="ex">The ex.</param> | |
/// <returns><c>true</c> if the error handler was set and called successfully; otherwise false.</returns> | |
internal bool RaiseErrorOccurred(Exception ex) | |
{ | |
bool handled = false; | |
if (this.ErrorOccurred != null) | |
{ | |
try | |
{ | |
this.ErrorOccurred(ex); | |
handled = true; | |
} | |
catch (Exception error) | |
{ | |
ApplicationLogger.Log(System.Diagnostics.TraceEventType.Error, "Error while trying to handle an exception.", error); | |
} | |
} | |
return handled; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment