I am creating a syntax application that parses ~ 20 sites, ~ 7-15 values from each. The pseudocode is as follows:
ParserA : ParserBase
{
public override SomeEntity Parse(...)
{
SomeEntity se = new SomeEntity();
...
return se;
}
}
ParserB : ParserBase {...}
ParserC : ParserBase {...}
...
and etc.
Once parsers have never succeeded with html (layouts happen to change over time), I need to implement exceptionHandling and Logging. I need to parse as much as possible and errors should be logged. I know two ways to handle this:
public override SomeEntity Parse(...)
{
SomeEntity se = new SomeEntity();
try {
...
}
catch (Exception e)
{
}
return se;
}
Pros: easy to implement
Cons: if I get exc with a value of 5, I have no chance to parse the value of 6.7, .. etc.
2)
ParserA : ParserBase
{
public override SomeEntity Parse(...)
{
try
{
}
catch(Exception e)
{
}
try
{
catch(Exception e)
{
}
try
{
catch(Exception e)
{
}
try
{
catch(Exception e)
{
}
...
}
}
Pros: everything that can be disassembled is analyzed;
Cons: too many copies (remember 20 parsers, 7-15 values in each.
, , Safecall, try-catch, ot. , :
SafeCall( () => {
});
:
try
{
catch(Exception e)
{
}
?