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


C# Exception.Match方法代码示例

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


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

示例1: HandlePipedException

        /// <summary>
        /// Handles the PipeTo exception
        /// </summary>
        /// <param name="system">
        /// The actor system.
        /// </param>
        /// <param name="recipient">The recipient of the payload and/or exception </param>
        /// <param name="sender">The sender</param>
        /// <param name="exception">
        /// The exception
        /// </param>
        /// <returns>
        /// Routed object
        /// </returns>
        private object HandlePipedException(ActorSystem system, ICanTell recipient, IActorRef sender, Exception exception)
        {
            exception = this.ExtractException(exception);
            exception.Match()
                .With<ParcelTimeoutException>(
                () =>
                    {
                        var maxNumberOfAttempts = system.Settings.Config.GetInt("ClusterKit.LargeObjects.MaxReadAttempts", 5);
                        if (this.ReceiveAttempt < maxNumberOfAttempts)
                        {
                            var rereadInterval = system.Settings.Config.GetTimeSpan("ClusterKit.LargeObjects.RereadInterval", TimeSpan.FromSeconds(5));
                            system.Scheduler.ScheduleTellOnce(rereadInterval, recipient, this, sender);
                        }
                        else
                        {
                            exception = new ParcelServerErrorException("Server is unresponsive");
                        }
                    });

            return exception;
        }
开发者ID:kantora,项目名称:ClusterKit,代码行数:35,代码来源:ParcelNotification.cs

示例2: PublishAndThrow

        private void PublishAndThrow(Exception reason, LogLevel level)
        {
            reason.Match().With<EndpointDisassociatedException>(endpoint => PublishDisassociated())
                .Default(msg => PublishError(reason, level));

            throw reason;
        }
开发者ID:MaciekLesiczka,项目名称:akka.net,代码行数:7,代码来源:Endpoint.cs

示例3: PublishAndThrow

        private void PublishAndThrow(Exception reason, LogLevel level)
        {
            reason.Match()
                .With<EndpointDisassociatedException>(endpoint => PublishDisassociated())
                .With<ShutDownAssociation>(shutdown => {}) // don't log an error for planned shutdowns
                .Default(msg => PublishError(reason, level));

            throw reason;
        }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:9,代码来源:Endpoint.cs


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