Coconut - 2005-03-14

I am considering methods that enhance error handling.  Currently, CookXml uses assert and generate debug messages only, which is suitable for testing/developing correct XMLs but not adequate for running/logging XMLs generated.  There will be an interface where different handlers can be plugged in.  The current idea in pseudo-code is:
            public interface ErrorHandler
            {
                public void reportError (String message, Exception ex);
            }
            public class StrictRuntimeErrorHandler implements ErrorHandler
            {
                private final static HashSet s_warningSet;
                private final static HashSet s_errorSet;
                private final static HashSet s_debugSet;

                // some static methods setting which message belongs to which.
                // all message strings in all CookXml will be static ones and
                // exceptions will be wrapped with more detailed messages.
                // ...

                public void reportError (String message, Exception ex)
                {
                    if (s_warningSet.contains (message)
                    {
                        CookXml.debug (message, ex);
                    }
                    else if (s_errorSet.contains (message)
                    {
                        throw new RuntimeException (message, ex);
                    }
                    else if (s_debugSet.contains (message)
                    {
                        assert CookXml.debug (message, ex);
                    }
                }
            }

Of course, there can be StrictRuntimeLogErrorHandler as well, just to show the possibilities.  Send me/post your suggestions since I really don't have much experience in this area but I want to do it right.  Thanks.