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


C# Exception.GetInnerException方法代码示例

本文整理汇总了C#中System.Exception.GetInnerException方法的典型用法代码示例。如果您正苦于以下问题:C# Exception.GetInnerException方法的具体用法?C# Exception.GetInnerException怎么用?C# Exception.GetInnerException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Exception的用法示例。


在下文中一共展示了Exception.GetInnerException方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestGetInnerException_Marked_DoesNotHaveInner_NestedInner

		public void TestGetInnerException_Marked_DoesNotHaveInner_NestedInner()
		{
			var inner = new Exception( "Inner", null );
			inner.Data[ ExceptionModifiers.IsMatrioshkaInner ] = null;
			var source = new Exception( "Outer", inner );

			var result = source.GetInnerException();

			Assert.That( result, Is.Null );
		}
开发者ID:Indifer,项目名称:Test,代码行数:10,代码来源:ExceptionExtensionsTest.cs

示例2: TestGetInnerException_NotMarked_AsIs

		public void TestGetInnerException_NotMarked_AsIs()
		{
			var nestedInner = new Exception( "Nested inner" );
			var inner = new Exception( "Inner", nestedInner );
			var source = new Exception( "Outer", inner );
	
			var result = source.GetInnerException();
			
			Assert.That( result, Is.SameAs( inner ) );
		}
开发者ID:Indifer,项目名称:Test,代码行数:10,代码来源:ExceptionExtensionsTest.cs

示例3: TestGetInnerException_Marked_HasInner_NestedInner

		public void TestGetInnerException_Marked_HasInner_NestedInner()
		{
			var nestedInner = new Exception( "Nested inner" );
			var inner = new Exception( "Inner", nestedInner );
			inner.Data[ ExceptionModifiers.IsMatrioshkaInner ] = null;
			var source = new Exception( "Outer", inner );

			var result = source.GetInnerException();

			Assert.That( result, Is.SameAs( nestedInner ) );
		}
开发者ID:Indifer,项目名称:Test,代码行数:11,代码来源:ExceptionExtensionsTest.cs

示例4: TestGetInnerException_InnerIsNull_Null

		public void TestGetInnerException_InnerIsNull_Null()
		{
			var source = new Exception();
			var result = source.GetInnerException();
			Assert.That( result, Is.Null );
		}
开发者ID:Indifer,项目名称:Test,代码行数:6,代码来源:ExceptionExtensionsTest.cs

示例5: ShowExceptionReporter

 private static void ShowExceptionReporter(Exception ex)
 {
     var inner = ex.GetInnerException();
     Logging.Client.Error("Unhandled Exception", inner);
     if (inner is InvalidZetboxGeneratedVersionException)
     {
         MessageBox.Show(
             WpfToolkitResources.InvalidZetboxGeneratedVersionException_Message,
             WpfToolkitResources.InvalidZetboxGeneratedVersionException_Title,
             MessageBoxButton.OK,
             MessageBoxImage.Stop);
     }
     else if (wpfResourcesInitialized && container != null)
     {
         var vmf = container.Resolve<IViewModelFactory>();
         var mdl = vmf.CreateViewModel<ExceptionReporterViewModel.Factory>().Invoke(container.Resolve<IZetboxContext>(), null, ex, container.Resolve<IScreenshotTool>().GetScreenshot());
         vmf.ShowDialog(mdl);
     }
     else
     {
         MessageBox.Show(ex.ToString());
     }
 }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:23,代码来源:App.cs

示例6: Show

        public bool Show(IZetboxContext ctx, Exception ex)
        {
            if (ctx == null) throw new ArgumentNullException("ctx");
            if (ex == null) return false;

            var inner = ex.GetInnerException();
            if (inner is ConcurrencyException)
            {
                var error = (ConcurrencyException)inner;
                vmf.CreateDialog(ctx, ZetboxContextExceptionHandlerResources.ConcurrencyException_Caption)
                    .AddTextBlock("empty", string.Empty, ZetboxContextExceptionHandlerResources.ConcurrencyException_Message)
                    .AddMultiLineString("details", ZetboxContextExceptionHandlerResources.DetailsLabel, string.Join("\n", error.Details.Select(e => string.Format(ZetboxContextExceptionHandlerResources.ConcurrencyException_DetailFormatString, e.ObjectAsString, e.ChangedBy, e.ChangedOn))), true, true)
                    .Show();
                return true;
            }
            else if (inner is ZetboxValidationException)
            {
                var error = (ZetboxValidationException)inner;
                vmf.CreateDialog(ctx, ZetboxContextExceptionHandlerResources.ZetboxValidationException_Caption)
                    .AddTextBlock("empty", string.Empty, ZetboxContextExceptionHandlerResources.ZetboxValidationException_Message)
                    .AddMultiLineString("details", ZetboxContextExceptionHandlerResources.ZetboxValidationException_ValueLabel, string.Format(ZetboxContextExceptionHandlerResources.ZetboxValidationException_ValueFormat, error.Message))
                    .Show();
                return true;
            }
            else if (inner is FKViolationException)
            {
                var error = (FKViolationException)inner;
                var details = string.Join("\n", error.Details.Select(e =>
                {
                    if (e.RelGuid == default(Guid) || e.RelGuid == Guid.Empty) return e.DatabaseError;
                    var rel = frozenCtx.FindPersistenceObject<Relation>(e.RelGuid);
                    return string.Format(
                        ZetboxContextExceptionHandlerResources.FKViolationException_DetailFormatString,
                        rel.A.Type.Name,
                        rel.B.Type.Name,
                        rel.A.RoleName,
                        rel.Verb,
                        rel.B.RoleName,
                        e.DatabaseError);
                }));
                vmf.CreateDialog(ctx, ZetboxContextExceptionHandlerResources.FKViolationException_Caption)
                    .AddTextBlock("error", string.Empty, ZetboxContextExceptionHandlerResources.FKViolationException_Message)
                    .AddMultiLineString("details", ZetboxContextExceptionHandlerResources.DetailsLabel, details, true, true)
                    .Show();
                return true;
            }
            else if (inner is UniqueConstraintViolationException)
            {
                var error = (UniqueConstraintViolationException)inner;
                var details = string.Join("\n", error.Details.Select(e =>
                {
                    if (e.IdxGuid == default(Guid) || e.IdxGuid == Guid.Empty) return e.DatabaseError;
                    var idx = frozenCtx.FindPersistenceObject<IndexConstraint>(e.IdxGuid);
                    return string.Format(
                        ZetboxContextExceptionHandlerResources.UniqueConstraintViolationException_DetailFormatString,
                        idx.Constrained.Name,
                        string.Join(", ", idx.Properties.Select(p => p.GetLabel())),
                        idx.Reason,
                        e.DatabaseError);
                }));
                vmf.CreateDialog(ctx, ZetboxContextExceptionHandlerResources.UniqueConstraintViolationException_Caption)
                    .AddTextBlock("error", string.Empty, ZetboxContextExceptionHandlerResources.UniqueConstraintViolationException_Message)
                    .AddMultiLineString("details", ZetboxContextExceptionHandlerResources.DetailsLabel, details, true, true)
                    .Show();
                return true;
            }

            return false;
        }
开发者ID:daszat,项目名称:zetbox,代码行数:69,代码来源:ZetboxContextExceptionHandler.cs


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