Hello,
Currently, classes with several exception handling code blocks are giving us some problems. The process can occasionally succeed while also failing occasionally for no apparent reason (no infolog). Following a code analysis, we discovered that the problem revolved around a section of code that consisted of nested exception handling practices. As you can see from the code below, there is one major try/catch statement that has a number of smaller ones inside of it. Additionally, we have a method that essentially has the identical statements as the primary method within the nested try statement. Given this, I was debating the proper course of action in cases like this. Should I get rid of the particular clauses and just use the main method's generic one instead?
public void firstMethod()
{
while (...)
{
try
{
// Validations
try
{
// My code
this.secondMethod();
// My code
}
catch (Exception::Deadlock)
{
// My code
}
catch (Exception::UpdateConflict)
{
// My code
}
catch (Exception::DuplicateKeyException)
{
// My code
}
catch (Exception::Error)
{
// My code
}
catch
{
// My code
}
}
catch (Exception::Error)
{
// My code
continue;
}
}
}
public void secondMethod()
{
try
{
// My code
}
catch (Exception::Deadlock)
{
// My code
}
catch (Exception::UpdateConflict)
{
// My code
}
catch (Exception::DuplicateKeyException)
{
// My code
}
catch (Exception::Error)
{
// My code
}
catch
{
// My code
}
}