I have this code :
try
{
result.FirstName = nodes[myIdx]
.Attributes["ows_FirstName"].Value;
}
catch { }
Now I don't know prior to invoking this call if the attribute I am looking for exists (Good ol sharepoint).
As a result the only linear way I can write the code I am looking to create is as such.
try
{
result.FirstName = nodes[myIdx]
.Attributes["ows_FirstName"]
.Value;
}
catch { }
try
{
result.LastName = nodes[myIdx]
.Attributes["ows_LastName"]
.Value;
}
catch { }
Now I have no use for the catch section of this code and end up with a huge amount of lines that are completely redundant.
Why couldn't I just do
try
{
result.FirstName = nodes[myIdx]
.Attributes["ows_FirstName"]
.Value;
}
So why are we explicitly forced to declare a catch block even when it isn't handled? I'm sure there is a good reason but can't work it out.
I know the importance of exception handling, but here is simply nothing exceptional about the exception and nothing I can do (nor need to do) to fix the behavior.