Is there any reason to use specific expetion classes MyException1 and MyException2 in this case?
public static void Main() { try { TestMethod(); } catch(Exception ex) { Console.Writeline(ex); } } private static void TestMethod() { // This method can throw Exception1 and Exception2 } public class MyException1 : Exception {} public class MyException2 : Exception {} I know that it makes sense in case when we have several catch blocks for each exception type. But in this case MyException1 and MyException2 are similar empty. These throwed exceptions will be casted to Exception class in the Main method. Maybe is it better not to create two similar Exception classes with such handling?
Exceptionis generally a bad idea. It's useful when logging, but you should (nearly) alwaysthrowagain. What would you do if you caught anOutOfMemoryException?