Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xml-dev] SAXException, checked, buy why?

From: Karl Waclawek <karl@--------.--->
To: Alan Gutierrez <alan-xml-dev@-----.--->
Date: 1/5/2005 2:29:00 PM
Alan Gutierrez wrote:

>>But again, if the Error class is abstract, one can subclass with
>>appropriate behaviour, known to the producer and consumer, but not
>>the API that just forwards the error.
> 
> 
>     Do you have this sketched out somewhere?

Maybe I am misunderstanding the whole problem, but what
I mean is so simple (in C#):

public abstract class SAXError
{
   // some always useful members
   public abstract Exception GetException();
   public abstract string GetMessage();
}

public interface IErrorHandler
{
   public void Error(SAXError error);
   ...
}

// known to content handler and application
public class MyAppError: SAXError
{
   public override Exception GetException() {...}
   public override string GetMessage() {...}
   // app specific members - data and/or behaviour
   public void Recover() {...}
}

// application level error handler, an instance of which
// is registered with the content handler
public class MyErrorHandler: IErrorHandler
{
   public void Error(SAXError error)
   {
     // type cast that does not throw exception
     MyAppError myError = error as MyAppError;
     if (myError == null) {  // not a MyAppError
       log(error);
       throw error.GetException();
     }
     else {
       myError.Recover();
     }
   }
}

In this case the API (IErrorHandler) has no notion
of MyAppError.Recover().

Karl


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent