private const string _failuretitle = "Attention"; // todo daro think of a better title. Warning? Ooops? Shit? public static void HandleError([NotNull] Exception exception, [CanBeNull] IMsg msg, [CanBeNull] string title = null) { Assert.ArgumentNotNull(exception, nameof(exception)); HandleError(ExceptionUtils.FormatMessage(exception), exception, msg, title); }
public void CanFormatComExceptionMessage() { var exception = new COMException("message", 2000); string message = ExceptionUtils.FormatMessage(exception); Console.WriteLine(message); Assert.AreEqual("message\r\n- Error code: 2000", message); }
public void CanFormatSimpleExceptionMessage() { var exception = new Exception("message"); string message = ExceptionUtils.FormatMessage(exception); Console.WriteLine(message); Assert.AreEqual("message", message); }
public void CanFormatMessageWithInnerException() { var inner = new COMException("inner", 2000); var outer = new Exception("outer", inner); string message = ExceptionUtils.FormatMessage(outer); Console.WriteLine(message); const string expected = "outer\r\n\r\n---> inner\r\n- Error code: 2000"; Assert.AreEqual(expected, message); }