If its various Exceptions that are thrown (i.e. different classes), then you will have to handle this with different catch attempts.
Usually you can:
try { // If I get a Exception when converting to number, // I will understand the error // but how could I know where in my `Try` statement was the error ? int valor = Convert.ToInt32(xmlnode[i].ChildNodes.Item(2).InnerText.Trim()); // A Lot of another validations here } Catch(IOException ioe) { // Handle, log } Catch(ArgumentNullException ane) { // Handle, log } Catch(Exception e) { // Handle, log and potentially rethrow }
You can also have individual catch attempts (like what, in my opinion, most people have), or nested catch attempts in your try block:
how
// First block try { // Convert here once } catch (Exception ex) { // Handle and log } // Second block try { // Convert here once } catch (Exception ex) { // Handle and log }
Not sure if this helps at all.
source share