public void DoSomething(int param1, int param2) { CallTracer.Output("DoSomething: Entering"); _variable1 = param1; AssignState(param2); CallTracer.Output("DoSomething: Exiting"); }
public static void TestExamples() { CallTracer.Start(System.Reflection.MethodBase.GetCurrentMethod()); CallTracer.Output("You should not get any output other than method names in this method context"); BetterExamples(); BadExamples(); CallTracer.End(); }
public void DoSomething3(int param1, int param2) { CallTracer.Output("DoSomething3: Entering"); int temp = param1; AssignState(param2); param1 = temp; CallTracer.Output("DoSomething3: Exiting"); }
public void AssignState(int param1) { CallTracer.Output("AssignState: Entering"); if (param1 < 1) { CallTracer.Output("AssignState: Throwing the exception"); throw new Exception(); } _variable2 = param1; CallTracer.Output("AssignState: Exiting"); }
public static void BetterExamples() { CallTracer.Start(System.Reflection.MethodBase.GetCurrentMethod()); int[] arr = BetterExampleErrorHandling.GetArrayValues(); for (int c1 = 0; c1 < arr.Length; c1++) { CallTracer.Output("Value is " + arr[c1]); } if (BetterExampleErrorHandling.GetStringValue().Length > 0) { CallTracer.Output("Not an empty String"); } CallTracer.End(); }
public static void Assertions() { CallTracer.Start(System.Reflection.MethodBase.GetCurrentMethod()); int param1 = 10; Assert.IsTrue(param1 > 0, new InstantiateException(AssertionFailure.Instantiate)); param1 = -1; CallTracer.Output("No exception at this point"); Assert.IsTrue(param1 > 0, new InstantiateException(AssertionFailure.Instantiate)); CallTracer.End(); }
public static void RunExceptions() { CallTracer.Start(System.Reflection.MethodBase.GetCurrentMethod()); ExceptionExamples obj = new ExceptionExamples(); try { obj.ThrowException(); } catch (Exception ex) { CallTracer.Output("----\n" + ex.TargetSite.ToString() + "\n-----"); CallTracer.Output("----\n" + ex.Source + "\n-----"); CallTracer.Output("----\n" + ex.StackTrace + "\n----"); } CallTracer.End(); }
public static void RunProgramState() { CallTracer.Start(System.Reflection.MethodBase.GetCurrentMethod()); try { ProgramState obj = new ProgramState(); CallTracer.Output("*****************************************"); obj.DoSomething(10, 10); CallTracer.Output("*****************************************"); obj.DoSomething2(0, 0); } catch (Exception ex) { CallTracer.Output("RunProgramState: Caught an exception"); } CallTracer.End(); }
public static void DoSomething() { CallTracer.Start(System.Reflection.MethodBase.GetCurrentMethod()); MyObject obj = new MyObject(); obj.DoSomething(-1); try { obj.DoSomethingAssert(-1); } catch (Exception except) { CallTracer.Output(except.Message); ; } CallTracer.End(); }
public void DoSomething2(int param1, int param2) { CallTracer.Output("DoSomething2: Entering"); int temp = _variable1; try { _variable1 = param1; AssignState(param2); } finally { _variable1 = temp; CallTracer.Output("DoSomething2: Exception in gear, but finally"); } CallTracer.Output("DoSomething2: Exiting"); }
public static void ExampleMethod() { CallTracer.Start(System.Reflection.MethodBase.GetCurrentMethod()); int[] args = new int[10]; try { for (int c1 = 0; ; c1++) { try { CallTracer.Output("Counter " + c1); } catch (Exception ex) { ; } args[c1] = 1; } } catch (IndexOutOfRangeException excep) { CallTracer.Output("Yupe hit the end of the array"); } CallTracer.End(); }
public static void BadExamples() { CallTracer.Start(System.Reflection.MethodBase.GetCurrentMethod()); int[] arr = BadExampleErrorHandling.GetArrayValues(); if (arr != null) { for (int c1 = 0; c1 < arr.Length; c1++) { CallTracer.Output("Value is " + arr[c1]); } } string value = BadExampleErrorHandling.GetStringValue(); if (value != null) { if (value.Length > 0) { CallTracer.Output("Not an empty String"); } } CallTracer.End(); }