Note that there are some explanatory texts on larger screens.

plurals
  1. POLogging Error Code Design, Input needed
    primarykey
    data
    text
    <p>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.</p> <p>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.</p> <p>I speculated at first at using an <code>enum</code> in each application to contain a list of possible ErrorCodes.</p> <p>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?</p> <p>ILog Interface: (Write Methods have overloads)</p> <pre><code>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 } </code></pre> <p>Log Class:</p> <pre><code>abstract class Log : ILog { public void FlagError (int errorCode) { if (errorCode == 0 || errorCode == int.MinValue || errorCode != (errorCode &amp; -errorCode)) { throw new IndexOutOfRangeException (); } if ((m_errorCode &amp; errorCode) == errorCode) return; m_errorCode += errorCode; } public int GetErrorCode () { return m_errorCode; } #region Other ILog Methods } </code></pre> <p>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.</p> <p>But Idk, any Ideas?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload