本文整理汇总了C#中System.Exception.BuildExceptionMessage方法的典型用法代码示例。如果您正苦于以下问题:C# Exception.BuildExceptionMessage方法的具体用法?C# Exception.BuildExceptionMessage怎么用?C# Exception.BuildExceptionMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Exception
的用法示例。
在下文中一共展示了Exception.BuildExceptionMessage方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Error
public void Error(Exception exception, string message = null)
{
if(String.IsNullOrEmpty(message))
{
message = exception.BuildExceptionMessage();
}
_logger.Error(exception, message);
}
示例2: GivenNoMessageInformation_WhenIFormatTheMessage_ThenTheMessageFormatShouldBeCorrect
public void GivenNoMessageInformation_WhenIFormatTheMessage_ThenTheMessageFormatShouldBeCorrect()
{
string message = "A message";
var e = new Exception(message);
string expected = "Message: " + message + Environment.NewLine
+ "Source: " + e.Source + Environment.NewLine
+ "Stack Trace: " + e.StackTrace + Environment.NewLine
+ "Target Site: " + e.TargetSite;
string actual = e.BuildExceptionMessage(null);
Assert.That(actual, Is.EqualTo(expected));
}
示例3: GivenAMessageInformation_WhenIFormatTheMessage_ThenTheMessageFormatShouldBeCorrect
public void GivenAMessageInformation_WhenIFormatTheMessage_ThenTheMessageFormatShouldBeCorrect()
{
string message = "A message";
string path = "A path";
string rawUrl = "A Url";
var messageInformationMock = new Mock<IMessageInformation>();
messageInformationMock.Setup(m => m.Path).Returns(path);
messageInformationMock.Setup(m => m.RawUrl).Returns(rawUrl);
var e = new Exception(message);
string expected = "Error in Path: " + path + Environment.NewLine
+ "Raw Url: " + rawUrl + Environment.NewLine
+ "Message: " + message + Environment.NewLine
+ "Source: " + e.Source + Environment.NewLine
+ "Stack Trace: " + e.StackTrace + Environment.NewLine
+ "Target Site: " + e.TargetSite;
string actual = e.BuildExceptionMessage(messageInformationMock.Object);
Assert.That(actual, Is.EqualTo(expected));
}
示例4: Fatal
public void Fatal(Exception x, string path, string url)
{
Fatal(x.BuildExceptionMessage(path, url));
}
示例5: Error
public void Error(Exception x, string path, string url)
{
Error(x.BuildExceptionMessage(path, url));
}
示例6: Fatal
public void Fatal(Exception x)
{
_logger.Fatal(x, x.BuildExceptionMessage());
}
示例7: Fatal
public void Fatal(Exception ex)
{
logger.Fatal(ex.BuildExceptionMessage());
}
示例8: Error
public void Error(Exception ex)
{
logger.Error(ex.BuildExceptionMessage());
}
示例9: Fatal
public void Fatal(Exception x)
{
Fatal(x.BuildExceptionMessage());
}
示例10: Error
public void Error(Exception x)
{
Error(x.BuildExceptionMessage());
}
示例11: Error
public void Error(Exception x)
{
_logger.Error(x, x.BuildExceptionMessage(), null);
}