public static void testErrors(int numOfIterations) { IList <string> dataList = setupData(); log.DebugFormat("Random IndexOutOfBounds Error generation for {} iterations ", numOfIterations); for (int i = 0; i < numOfIterations; i++) { try { Thread.Sleep(100); int data = RandomUtil.generateRandom(10); string returnString = dataList[data]; } catch (Exception e) { //log the exception and keep chugging log.Error(e.Message); } } }
public static void testErrors(int numOfIterations) { IList <string> dataList = setupData(); log.DebugFormat("Random NullPointer Error generation for {} iterations ", numOfIterations); for (int i = 0; i < numOfIterations; i++) { sleep(); int randNum = RandomUtil.generateRandom(4); log.DebugFormat("Case number is {}", randNum); switch (randNum) { case 0: testCaughtNulls(getRandomString(dataList)); break; case 1: try { testUncaughtNulls(getRandomString(dataList)); } catch (Exception e) { log.ErrorFormat("This error was uncaught", e.Message); } break; case 2: testSwallowedNulls(getRandomString(dataList)); break; case 3: intermediateMethod(getRandomString(dataList)); break; } } }