• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ExceptionHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ExceptionHandler的典型用法代码示例。如果您正苦于以下问题:C# ExceptionHandler类的具体用法?C# ExceptionHandler怎么用?C# ExceptionHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ExceptionHandler类属于命名空间,在下文中一共展示了ExceptionHandler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: DelHandler

 /// <summary>
 /// 移除处理类
 /// </summary>
 /// <param name="handler"></param>
 private static void DelHandler(ExceptionHandler handler)
 {
     if (handlers.ContainsKey(handler.ToString()))
     {
         handlers.Remove(handler.ToString());
     }
 }
开发者ID:rbmyself,项目名称:ipmsnew,代码行数:11,代码来源:ExceptionHandlerFactory.cs


示例2: TryParse

		private static ValueOrError<CrontabSchedule> TryParse(string expression, ExceptionHandler onError)
		{
			if (expression == null)
				throw new ArgumentNullException("expression");

			var tokens = expression.Split(_separators, StringSplitOptions.RemoveEmptyEntries);

			if (tokens.Length != 5)
			{
				return ErrorHandling.OnError(() => new CrontabException(string.Format(
						   "'{0}' is not a valid crontab expression. It must contain at least 5 components of a schedule "
						   + "(in the sequence of minutes, hours, days, months, days of week).",
						   expression)), onError);
			}

			var fields = new CrontabField[5];

			for (var i = 0; i < fields.Length; i++)
			{
				var field = CrontabField.TryParse((CrontabFieldKind)i, tokens[i], onError);
				if (field.IsError)
					return field.ErrorProvider;

				fields[i] = field.Value;
			}

			return new CrontabSchedule(fields[0], fields[1], fields[2], fields[3], fields[4]);
		}
开发者ID:ASK-sa,项目名称:ASK.ServEasy,代码行数:28,代码来源:CrontabSchedule.cs


示例3: AddHandler

 /// <summary>
 /// 添加处理类
 /// </summary>
 /// <param name="handler"></param>
 private static void AddHandler(ExceptionHandler handler)
 {
     if (!handlers.ContainsKey(handler.ToString()))
     {
         handlers.Add(handler.ToString(), handler);
     }
 }
开发者ID:rbmyself,项目名称:ipmsnew,代码行数:11,代码来源:ExceptionHandlerFactory.cs


示例4: ExceptionHandlerTreeNode

 public ExceptionHandlerTreeNode( ExceptionHandler handler ) :
     base( TreeViewImage.Method, handler )
 {
     this.handler = handler;
     this.Text = handler.Options.ToString();
     this.EnableLatePopulate();
 }
开发者ID:jogibear9988,项目名称:ormbattle,代码行数:7,代码来源:ExceptionHandlerTreeNode.cs


示例5: Main

 static void Main()
 {
     ExceptionHandler EH = new ExceptionHandler();
         AppDomain.CurrentDomain.UnhandledException += EH.ThreadExceptionHandle;
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         _LoginForm = new LoginForm();
         Application.Run(_LoginForm); // spawn
 }
开发者ID:justinwillcott,项目名称:huggle,代码行数:9,代码来源:Program.cs


示例6: OnError

		internal static ExceptionProvider OnError(ExceptionProvider provider, ExceptionHandler handler)
		{
			Debug.Assert(provider != null);

			if (handler != null)
				handler(provider());

			return provider;
		}
开发者ID:ASK-sa,项目名称:ASK.ServEasy,代码行数:9,代码来源:ErrorHandling.cs


示例7: When_rethrows_if_no_handler

        public void When_rethrows_if_no_handler()
        {
            var exceptions = new Dictionary<Type, Action>();
            var exception = new ExceptionHandler(exceptions);
            int invoke = 0;
            Action action = () => invoke++;

            Assert.Throws<NotImplementedException>(() => exception.On<AbandonedMutexException>(action).When(() => { throw new NotImplementedException(); }));
        }
开发者ID:garfieldmoore,项目名称:Exceptions,代码行数:9,代码来源:OnSpec.cs


示例8: Main

 static void Main()
 {
     ExceptionHandler EH = new ExceptionHandler();
     AppDomain.CurrentDomain.UnhandledException += EH.ThreadExceptionHandle;
     Application.Init ();
     LoginForm = new Forms.LoginForm();
     LoginForm.Show ();
     Application.Run ();
 }
开发者ID:se4598,项目名称:huggle,代码行数:9,代码来源:Program.cs


示例9: Handle_ExceptionWhichNoSpecificHandlerCanHandle_RepositoryViolationExceptionThrown

        public void Handle_ExceptionWhichNoSpecificHandlerCanHandle_RepositoryViolationExceptionThrown()
        {
            ExceptionHandler handler = new ExceptionHandler();
            Exception e = new Exception();

            Action act = () => handler.Handle(e);

            act.ShouldThrow<RepositoryViolationException>(actual => ReferenceEquals(actual.InnerException, e));
        }
开发者ID:popcatalin81,项目名称:DataAccess,代码行数:9,代码来源:ExceptionHandlerTests.cs


示例10: When_invokes_target

        public void When_invokes_target()
        {
            var exceptions = new Dictionary<Type, Action>();
            var exception = new ExceptionHandler(exceptions);
            int invoke = 0;
            Action action = () => Console.WriteLine("caught");

            exception.On<Exception>(action).When(() => invoke++);
            invoke.ShouldBe(1);
        }
开发者ID:garfieldmoore,项目名称:Exceptions,代码行数:10,代码来源:OnSpec.cs


示例11: InstallExceptionHandler

		public static void InstallExceptionHandler(this Application application, ExceptionHandler exceptionHandler)
		{
			const string WarningFormat =
				"If the TaskScheduler used does not implements the {0} interface," +
				" it could not intercept exceptions thrown in secondary threads.";

			Debug.WriteLine(string.Format(WarningFormat, typeof(ILoggerTaskScheduler).Name));

			singletonExceptionHandler.Set(exceptionHandler);
			exceptionHandler.Install();
		}
开发者ID:matteomigliore,项目名称:HSDK,代码行数:11,代码来源:ApplicationExtensions.cs


示例12: When_invokes_exception_handler_on_exception

        public void When_invokes_exception_handler_on_exception()
        {
            var exceptions = new Dictionary<Type, Action>();
            var exception = new ExceptionHandler(exceptions);
            int invoke = 0;
            Action action = () => invoke++;

            exception.On<NotImplementedException>(action).When(() => { throw new NotImplementedException(); });

            invoke.ShouldBe(1);
        }
开发者ID:garfieldmoore,项目名称:Exceptions,代码行数:11,代码来源:OnSpec.cs


示例13: Throw

 private bool Throw(ExceptionHandler handler)
 {
     try
     {
         throw new Exception("ExceptionHandlerTests");
     }
     catch (Exception e)
     {
         return handler.HandleException(e);
     }
 }
开发者ID:tarik-s,项目名称:Meticulous,代码行数:11,代码来源:ExceptionHandlerTests.cs


示例14: On_Exception_adds_exception_and_target_invocation

        public void On_Exception_adds_exception_and_target_invocation()
        {
            var exceptions = new Dictionary<Type, Action>();
            var exception = new ExceptionHandler(exceptions);
            Action action = () => Console.WriteLine("caught");

            exception.On<Exception>(action);

            exceptions.ContainsKey(typeof(Exception));
            exceptions.ContainsValue(action);
            exceptions.Count.ShouldBe(1);
        }
开发者ID:garfieldmoore,项目名称:Exceptions,代码行数:12,代码来源:OnSpec.cs


示例15: handleException

        static void handleException(Exception e)
        {
            var handler = new ExceptionHandler
            {
                Exception = e,
                LoggedOnUser = GlobalProperties.loggedOnUser,
                Mode = Mode.Online
            };

            handler.handleException();
            MessageBox.Show("An error was detected. An email has been sent to Development. LAD will now close.", "Error");
            Application.Exit();
        }
开发者ID:robertfall,项目名称:LAD,代码行数:13,代码来源:Program.cs


示例16: Run

        public void Run(Proc procediment)
        {
            ExceptionHandler eh = new ExceptionHandler();

            AppDomain.CurrentDomain.UnhandledException += eh.OnThreadException;

            procediment.Invoke();

            AppDomain.CurrentDomain.UnhandledException -= eh.OnThreadException;

            if (eh.Count > 0)
                Assert.Fail("Engine Validator concurrent issues. Concurrent issues count {0}", eh.Count);
        }
开发者ID:spib,项目名称:nhcontrib,代码行数:13,代码来源:ThreadSafeFixture.cs


示例17: handleException

        private static void handleException(Exception ex)
        {
            var handler = new ExceptionHandler
            {
                Exception = ex,
                LoggedOnUser = Global.loggedOnUser,
                Mode = Global.systemMode

            };

            handler.handleException();
            MessageBox.Show("An error was detected. An email has been sent to Development. LAD will now close.", "Error");
            Application.Exit();
        }
开发者ID:robertfall,项目名称:LAD,代码行数:14,代码来源:LoginForm.cs


示例18: ContinueProcessing

    void ContinueProcessing()
    {
        body = Method.Body;

        body.SimplifyMacros();

        var ilProcessor = body.GetILProcessor();

        var returnFixer = new ReturnFixer
        {
            Method = Method
        };
        returnFixer.MakeLastStatementReturn();

        exceptionVariable = new VariableDefinition(ModuleWeaver.ExceptionType);
        body.Variables.Add(exceptionVariable);
        messageVariable = new VariableDefinition(ModuleWeaver.ModuleDefinition.TypeSystem.String);
        body.Variables.Add(messageVariable);
        paramsArrayVariable = new VariableDefinition(ModuleWeaver.ObjectArray);
        body.Variables.Add(paramsArrayVariable);


        var tryCatchLeaveInstructions = Instruction.Create(OpCodes.Leave, returnFixer.NopBeforeReturn);

        var methodBodyFirstInstruction = GetMethodBodyFirstInstruction();

        var catchInstructions = GetCatchInstructions().ToList();

        ilProcessor.InsertBefore(returnFixer.NopBeforeReturn, tryCatchLeaveInstructions);

        ilProcessor.InsertBefore(returnFixer.NopBeforeReturn, catchInstructions);

        var handler = new ExceptionHandler(ExceptionHandlerType.Catch)
        {
            CatchType = ModuleWeaver.ExceptionType,
            TryStart = methodBodyFirstInstruction,
            TryEnd = tryCatchLeaveInstructions.Next,
            HandlerStart = catchInstructions.First(),
            HandlerEnd = catchInstructions.Last().Next
        };

        body.ExceptionHandlers.Add(handler);

        body.InitLocals = true;
        body.OptimizeMacros();
    }
开发者ID:AndreGleichner,项目名称:Anotar,代码行数:46,代码来源:OnExceptionProcessor.cs


示例19: Implementation

		internal static void Implementation( Action action, ExceptionHandler canHandle, ICircuitBreakerState breaker )
		{
			if( breaker.IsBroken )
				throw breaker.LastException;

			try
			{
				action();
				breaker.Reset();
			}
			catch( Exception ex )
			{
				if( !canHandle( ex ) )
					throw;
				breaker.TryBreak( ex );
				throw;
			}
		}
开发者ID:slav,项目名称:Netco,代码行数:18,代码来源:CircuitBreakerPolicy.cs


示例20: ImplementationAsync

		internal static async Task ImplementationAsync( Func< Task > action, ExceptionHandler canHandle, ICircuitBreakerState breaker )
		{
			if( breaker.IsBroken )
				throw breaker.LastException;

			try
			{
				await action().ConfigureAwait( false );
				breaker.Reset();
			}
			catch( Exception ex )
			{
				if( !canHandle( ex ) )
					throw;
				breaker.TryBreak( ex );
				throw;
			}
		}
开发者ID:slav,项目名称:Netco,代码行数:18,代码来源:CircuitBreakerPolicy.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ExceptionType类代码示例发布时间:2022-05-24
下一篇:
C# ExceptionEventArgs类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap