public void Handle(IExceptionHandlerContext <RestartAsAdministratorCancelledException> context) { context.IsHandled = true; navigator.Notify("Unauthorized", "The operation requires elevated privilege which has not been given.", Navigator.MessageType.Error); application.Shutdown(); }
protected override Task HandleAsync( CommandTest command, Exception exception, IExceptionHandlerContext context, CancellationToken cancellationToken) { throw new NotImplementedException(); }
public Task HandleAsync( Ping request, Exception exception, IExceptionHandlerContext <int> context, CancellationToken cancellationToken) { throw new NotImplementedException(); }
Task IQueryExceptionHandler <TQuery, TResult> .HandleAsync( TQuery query, Exception exception, IExceptionHandlerContext <TResult> context, CancellationToken cancellationToken) { return(HandleAsync(query, (TException)exception, context, cancellationToken)); }
public Task HandleAsync( CommandTest request, Exception exception, IExceptionHandlerContext <VoidUnit> context, CancellationToken cancellationToken) { throw new NotImplementedException(); }
public Task HandleAsync( Ping request, Exception exception, IExceptionHandlerContext <int> context, CancellationToken cancellationToken) { context.ExceptionWasHandled(Value); return(TaskBridge.CompletedTask); }
Task IQueryExceptionHandler <TQuery, TResult> .HandleAsync( TQuery query, Exception exception, IExceptionHandlerContext <TResult> context, CancellationToken cancellationToken) { Handle(query, (TException)exception, context, cancellationToken); return(TaskBridge.CompletedTask); }
Task IQueryExceptionHandler <TCommand, VoidUnit> .HandleAsync( TCommand command, Exception exception, IExceptionHandlerContext <VoidUnit> context, CancellationToken cancellationToken) { using var localContext = new ExceptionHandlerContext(context); Handle(command, (TException)exception, localContext, cancellationToken); return(TaskBridge.CompletedTask); }
async Task IQueryExceptionHandler <TCommand, VoidUnit> .HandleAsync( TCommand command, Exception exception, IExceptionHandlerContext <VoidUnit> context, CancellationToken cancellationToken) { using var localContext = new ExceptionHandlerContext(context); await HandleAsync( command, (TException)exception, localContext, cancellationToken ) .ConfigureAwait(false); }
public void Handle(IExceptionHandlerContext <Exception> context) { StringBuilder message = new StringBuilder(); string exceptionMessage = context.Exception.ToString(); if (exceptionMessage.Length > 800) { exceptionMessage = exceptionMessage.Substring(0, 800); } message.AppendLine(exceptionMessage); bool result = navigator.Confirm("Unhandled exception - Do you want to kill the aplication?", message.ToString(), Navigator.MessageType.Error); if (!result) { context.IsHandled = true; } }
private void HandleInternal <T>(IExceptionHandlerContext <T> context) where T : Exception { processService.RestartAsAdministrator(); context.IsHandled = true; }
void IExceptionHandler <IExceptionHandlerContext <UnauthorizedAccessException> > .Handle(IExceptionHandlerContext <UnauthorizedAccessException> context) => HandleInternal(context);
public void Handle(IExceptionHandlerContext <T> context) { context.IsHandled = IsHandled; Count++; }
/// <summary> /// Handles a <typeparamref name="TException"/> /// occured in <see cref="ICommandHandler{TCommand}"/>. /// </summary> /// <param name="command">A command sent to <see cref="IMediator"/>.</param> /// <param name="exception"> /// An exception occured in <see cref="ICommandHandler{TCommand}"/>. /// </param> /// <param name="context"> /// An information about the progress of exception handling. /// </param> /// <param name="cancellationToken"> /// A cancellation token that should be used to cancel the work. /// </param> /// <returns>A task that represents exception handling.</returns> protected abstract Task HandleAsync( TCommand command, TException exception, IExceptionHandlerContext context, CancellationToken cancellationToken );
/// <summary> /// Handles a <typeparamref name="TException"/> /// occured in <see cref="ICommandHandler{TCommand}"/>. /// </summary> /// <param name="command">A command sent to <see cref="IMediator"/>.</param> /// <param name="exception"> /// An exception occured in <see cref="ICommandHandler{TCommand}"/>. /// </param> /// <param name="context"> /// An encapsulated information about the progress of exception handling. /// </param> /// <param name="cancellationToken"> /// A cancellation token that should be used to cancel the work. /// </param> protected abstract void Handle( TCommand command, TException exception, IExceptionHandlerContext context, CancellationToken cancellationToken );
/// <summary> /// Handles a <typeparamref name="TException"/> /// occured in <see cref="IQueryHandler{TQuery, TResult}"/>. /// </summary> /// <param name="query"></param> /// <param name="exception"> /// An exception occured in <see cref="IQueryHandler{TQuery, TResult}"/>. /// </param> /// <param name="context"> /// An information about the progress of exception handling. /// </param> /// <param name="cancellationToken"> /// A cancellation token that should be used to cancel the work. /// </param> /// <returns>A task that represents exception handling.</returns> protected abstract Task HandleAsync( TQuery query, TException exception, IExceptionHandlerContext <TResult> context, CancellationToken cancellationToken );
void IExceptionHandler <IExceptionHandlerContext <PackageFileExtractionException> > .Handle(IExceptionHandlerContext <PackageFileExtractionException> context) { navigator.Notify("Package Install Error", $"Error extracting file to '{context.Exception.FilePath}'", Navigator.MessageType.Error); context.IsHandled = true; }
void IExceptionHandler <IExceptionHandlerContext <FatalProtocolException> > .Handle(IExceptionHandlerContext <FatalProtocolException> context) { if (context.Exception.InnerException is HttpRequestException && context.Exception.InnerException.InnerException is WebException webException) { navigator.Notify("Communcation Error", GetMessage(webException), Navigator.MessageType.Error); context.IsHandled = true; } }
void IExceptionHandler <IExceptionHandlerContext <PackageFileRemovalException> > .Handle(IExceptionHandlerContext <PackageFileRemovalException> context) { navigator.Notify("Package Removal Error", $"Error deleting file '{context.Exception.FilePath}'", Navigator.MessageType.Error); context.IsHandled = true; }
public ExceptionHandlerContext(IExceptionHandlerContext <VoidUnit> context) { _context = context; }
void IExceptionHandler <IExceptionHandlerContext <PackagesConfigWriterException> > .Handle(IExceptionHandlerContext <PackagesConfigWriterException> context) => HandleInternal(context);
void IExceptionHandler <IExceptionHandlerContext <NuGetConfigurationException> > .Handle(IExceptionHandlerContext <NuGetConfigurationException> context) => HandleInternal(context);
public void Handle(IExceptionHandlerContext <T> context) { innerHandler.Handle(context.Exception); }