public ExceptionHandlerBase <TMessageDescription> GetHandler(ExceptionHandlingPolicy policy)
        {
            if (_supportedPolicies.TryGetValue(policy, out var handler) == false)
            {
                throw new NotSupportedException($"Policy {policy.ToString()} is not supported");
            }

            return(handler);
        }
Exemplo n.º 2
0
        protected ExceptionHandlerBase(ILogger logger, ExceptionHandlingPolicy exceptionHandlingPolicy)
        {
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            Logger = logger;
            ExceptionHandlingPolicy = exceptionHandlingPolicy;
        }
Exemplo n.º 3
0
        public static void RegardlessOfExceptionHandlingPolicy(this Action assertion, Action cleanupCase)
        {
            cleanupCase = cleanupCase ?? new Action(() => { });

            ExceptionHandlingPolicy defaultSettings = DiagnosticSettings.Custom.ExceptionHandlingPolicy;

            DiagnosticSettings.Custom.ExceptionHandlingPolicy = ExceptionHandlingPolicy.TurnOffTheSubscription;
            assertion(); cleanupCase();

            DiagnosticSettings.Custom.ExceptionHandlingPolicy = ExceptionHandlingPolicy.FailFast;
            assertion(); cleanupCase();

            DiagnosticSettings.Custom.ExceptionHandlingPolicy = defaultSettings;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Handles the exception.
 /// </summary>
 /// <param name="exception">The exception.</param>
 /// <param name="policy">The policy.</param>
 /// <returns>bool</returns>
 public bool HandleException(Exception exception, ExceptionHandlingPolicy policy)
 {
     return(ExceptionPolicy.HandleException(exception, policy.GetDescription()));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Handles the exception.
 /// </summary>
 /// <param name="exception">The exception.</param>
 /// <param name="policy">The policy.</param>
 /// <param name="execptionToThrow">The execption to throw.</param>
 /// <returns>bool</returns>
 public bool HandleException(Exception exception, ExceptionHandlingPolicy policy, out Exception execptionToThrow)
 {
     return(ExceptionPolicy.HandleException(exception, policy.GetDescription(), out execptionToThrow));
 }
Exemplo n.º 6
0
 internal void Reset()
 {
     this.exceptionHandlingPolicy = xReactor.ExceptionHandlingPolicy.FailFast;
 }