當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。