I have some code as such
try { result.FirstName = nodes[myIdx].Attributes["ows_FirstName"].Value; } catch { }
Now I don’t know before calling this call if the attribute I'm looking for exists (Good ol sharepoint).
As a result, the only linear way that I can write the code I'm looking for to create as such is.
try { result.FirstName = nodes[myIdx].Attributes["ows_FirstName"].Value; } catch { } try { result.LastName = nodes[myIdx].Attributes["ows_LastName"].Value; } catch { } ....
Now I do not use the catch section of this code and get a huge number of lines that are completely redundant.
Why I couldn’t just do
try { result.FirstName = nodes[myIdx].Attributes["ows_FirstName"].Value; }
So why are we explicitly forced to declare a catch block, even if it is not being processed? I am sure that there is a good reason, but I can’t solve it.
EDIT: Before everyone starts to leave me, that swallowing an exception is bad, blah blah blah. We (and I) all know these arguments, but in this (and many) real-world scenarios there is nothing exceptional in the exception, and I cannot do (or should not) do anything to correct the behavior.
source share