当前位置: 首页>>代码示例>>C#>>正文


C# HttpError.ToODataError方法代码示例

本文整理汇总了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);
        }
开发者ID:naulizzang,项目名称:aspnetwebstack,代码行数:12,代码来源:ODataHttpErrorExtensionsTest.cs

示例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);
        }
开发者ID:naulizzang,项目名称:aspnetwebstack,代码行数:14,代码来源:ODataHttpErrorExtensionsTest.cs

示例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);
        }
开发者ID:naulizzang,项目名称:aspnetwebstack,代码行数:19,代码来源:ODataHttpErrorExtensionsTest.cs

示例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);
        }
开发者ID:naulizzang,项目名称:aspnetwebstack,代码行数:20,代码来源:ODataHttpErrorExtensionsTest.cs


注:本文中的HttpError.ToODataError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。