public static string GetErrorMessage(Exception exception) { var fullMethodNames = new StackTraceWrapper(exception).GetFullMethodNames(); var messages = fullMethodNames.FindAll(name => ErrorMap.ContainsKey(name)).Select(name => ErrorMap[name]).ToList(); messages.Reverse(); return(String.Join(" -> ", messages)); }
public void ShouldBeAbleToGetFullNameOfMethodsFromStackTrace() { try { new TestClass().ThrowException(); } catch (Exception ex) { var stackTraceWrapper = new StackTraceWrapper(ex); var fullMethodNames = stackTraceWrapper.GetFullMethodNames(); Assert.That(fullMethodNames, Has.Member("UnitTests.TestErrorDiscription.Method1")); } }
public void SetUp() { _stackTraceWrapper = new StackTraceWrapper(); }