本文整理汇总了C#中HttpError.ToODataError方法的典型用法代码示例。如果您正苦于以下问题:C# HttpError.ToODataError方法的具体用法?C# HttpError.ToODataError怎么用?C# HttpError.ToODataError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpError
的用法示例。
在下文中一共展示了HttpError.ToODataError方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToODataError_CopiesMessageDetailToInnerError
public void ToODataError_CopiesMessageDetailToInnerError()
{
var error = new HttpError();
error["Message"] = "error";
error["MessageDetail"] = "messagedetail";
ODataError oDataError = error.ToODataError();
Assert.Equal("error", oDataError.Message);
Assert.Equal("messagedetail", oDataError.InnerError.Message);
Assert.Null(oDataError.InnerError.InnerError);
}
示例2: ToODataError_CopiesInnerExceptionInformation
public void ToODataError_CopiesInnerExceptionInformation()
{
Exception innerException = new ArgumentException("innerException");
Exception exception = new InvalidOperationException("exception", innerException);
var error = new HttpError(exception, true);
ODataError oDataError = error.ToODataError();
Assert.Equal("An error has occurred.", oDataError.Message);
Assert.Equal("exception", oDataError.InnerError.Message);
Assert.Equal("System.InvalidOperationException", oDataError.InnerError.TypeName);
Assert.Equal("innerException", oDataError.InnerError.InnerError.Message);
Assert.Equal("System.ArgumentException", oDataError.InnerError.InnerError.TypeName);
}
示例3: ToODataError_CopiesModelStateErrorsToInnerError
public void ToODataError_CopiesModelStateErrorsToInnerError()
{
ModelStateDictionary dict = new ModelStateDictionary();
string errorMessage1 = "Object reference not set to an instance of an object.";
string errorMessage2 = "Some ModelState error";
string parameter1Name = "parameter1";
string parameter2Name = "parameter2";
dict.AddModelError(parameter1Name, new InvalidOperationException(errorMessage1));
dict.AddModelError(parameter2Name, errorMessage2);
var error = new HttpError(dict, includeErrorDetail: true);
ODataError oDataError = error.ToODataError();
Assert.Equal(
parameter1Name + " : " + errorMessage1 + Environment.NewLine +
parameter2Name + " : " + errorMessage2 + Environment.NewLine,
oDataError.InnerError.Message);
}
示例4: ToODataError_CopiesAllErrorProperties
public void ToODataError_CopiesAllErrorProperties()
{
var error = new HttpError();
error["Message"] = "error";
error["MessageLanguage"] = "language";
error["ErrorCode"] = "42";
error["ExceptionMessage"] = "exception";
error["ExceptionType"] = "System.ReallyBadException";
error["StackTrace"] = "stacktrace";
ODataError oDataError = error.ToODataError();
Assert.Equal("error", oDataError.Message);
Assert.Equal("language", oDataError.MessageLanguage);
Assert.Equal("42", oDataError.ErrorCode);
Assert.Equal("exception", oDataError.InnerError.Message);
Assert.Equal("System.ReallyBadException", oDataError.InnerError.TypeName);
Assert.Equal("stacktrace", oDataError.InnerError.StackTrace);
Assert.Null(oDataError.InnerError.InnerError);
}