So, I'm stuck on a little problem. I was curious if anyone had some extra input they might be willing to give on this design.
I have an ILog interface which has two methods exposed for the Error Code logging part of the design. FlagError and GetErrorCode; FlagError sets a bit on an integer, each bit representing that a certain error was thrown., GetErrorCode (which would be the return value for the Main method) returns that said integer.
I speculated at first at using an enum
in each application to contain a list of possible ErrorCodes.
But the problem is, how exactly would I relay to the users that error code 'XYZ' represents that the application hit these un-normal states during execution in a friendly way?
ILog Interface: (Write Methods have overloads)
interface ILog
{
void FlagError (int errorCode);
int GetErrorCode ();
#region Other ILog Methods
void WriteError(string message);
void WriteWarning(string message);
void WriteInfo(string message);
void WriteDebug(string message);
#endregion
}
Log Class:
abstract class Log : ILog
{
public void
FlagError (int errorCode)
{
if (errorCode == 0 || errorCode == int.MinValue || errorCode != (errorCode & -errorCode))
{
throw new IndexOutOfRangeException ();
}
if ((m_errorCode & errorCode) == errorCode)
return;
m_errorCode += errorCode;
}
public int
GetErrorCode ()
{
return m_errorCode;
}
#region Other ILog Methods
}
I speculated using an attribute on each enum value with a description of that error, and then just having a little process or something to help 'parse' the error code into a human readable description.
But Idk, any Ideas?