本文整理汇总了C#中ExceptionHandler类的典型用法代码示例。如果您正苦于以下问题:C# ExceptionHandler类的具体用法?C# ExceptionHandler怎么用?C# ExceptionHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExceptionHandler类属于命名空间,在下文中一共展示了ExceptionHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DelHandler
/// <summary>
/// 移除处理类
/// </summary>
/// <param name="handler"></param>
private static void DelHandler(ExceptionHandler handler)
{
if (handlers.ContainsKey(handler.ToString()))
{
handlers.Remove(handler.ToString());
}
}
示例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]);
}
示例3: AddHandler
/// <summary>
/// 添加处理类
/// </summary>
/// <param name="handler"></param>
private static void AddHandler(ExceptionHandler handler)
{
if (!handlers.ContainsKey(handler.ToString()))
{
handlers.Add(handler.ToString(), handler);
}
}
示例4: ExceptionHandlerTreeNode
public ExceptionHandlerTreeNode( ExceptionHandler handler ) :
base( TreeViewImage.Method, handler )
{
this.handler = handler;
this.Text = handler.Options.ToString();
this.EnableLatePopulate();
}
示例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
}
示例6: OnError
internal static ExceptionProvider OnError(ExceptionProvider provider, ExceptionHandler handler)
{
Debug.Assert(provider != null);
if (handler != null)
handler(provider());
return provider;
}
示例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(); }));
}
示例8: Main
static void Main()
{
ExceptionHandler EH = new ExceptionHandler();
AppDomain.CurrentDomain.UnhandledException += EH.ThreadExceptionHandle;
Application.Init ();
LoginForm = new Forms.LoginForm();
LoginForm.Show ();
Application.Run ();
}
示例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));
}
示例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);
}
示例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();
}
示例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);
}
示例13: Throw
private bool Throw(ExceptionHandler handler)
{
try
{
throw new Exception("ExceptionHandlerTests");
}
catch (Exception e)
{
return handler.HandleException(e);
}
}
示例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);
}
示例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();
}