Is this WPF error handling a good idea ?
Posted
by
Adiel
on Stack Overflow
See other posts from Stack Overflow
or by Adiel
Published on 2010-12-30T13:41:53Z
Indexed on
2010/12/30
13:54 UTC
Read the original article
Hit count: 259
I have a multi threaded wpf application with various HW interfaces.
I want to react to several HW failures that can happen.
For example :
one of the interfaces is a temperature sensor and i want that from a certain temp. a meesage would appear and notify the user that it happened.
i came up with the follwing design :
/// <summary>
/// This logic reacts to errors that occur during the system run.
/// The reaction is set by the component that raised the error.
/// </summary>
public class ErrorHandlingLogic : Logic
{
}
the above class would consume ErrorEventData that holds all the information about the error that occurred.
public class ErrorEventData : IEventData
{
#region public enum
public enum ErrorReaction
{
}
#endregion public enum
#region Private Data Memebers and props
private ErrorReaction m_ErrorReaction;
public ErrorReaction ErrorReactionValue
{
get { return m_ErrorReaction; }
set { m_ErrorReaction = value; }
}
private string m_Msg;
public string Msg
{
get { return m_Msg; }
set { m_Msg = value; }
}
private string m_ComponentName;
public string ComponentName
{
get { return m_ComponentName; }
set { m_ComponentName = value; }
}
#endregion Private Data Memebers and props
public ErrorEventData(ErrorReaction reaction, string msg, string componenetName)
{
m_ErrorReaction = reaction;
m_Msg = msg;
m_ComponentName = componenetName;
}
}
the above ErrorHandlingLogic would decide what to do with the ErrorEventData sent to him from various components of the application.
if needed it would be forwarded to the GUI to display a message to the user.
so what do you think is it a good design ?
thanks, Adiel.
© Stack Overflow or respective owner