示例#1
0
        /// <summary>
        /// Fires an instrumentation event.
        /// </summary>
        /// <param name="name">The name of the exception policy.</param>
        /// <param name="e">The caught exception.</param>
        protected override void PublishFailureEvent(string name, Exception e)
        {
            string message = CreateProviderNotFoundExceptionMessage(currentException, name);

            ExceptionHandlingConfigFailureEvent.Fire(message);
            ExceptionUtility.LogHandlingException(name, e, null, currentException);
        }
        /// <summary>
        /// <para>Publish an instrumentation event that indicates there was an error while attempting to create a provider.</para>
        /// </summary>
        /// <param name="configurationName"><para>The name of the configuration object.</para></param>
        /// <param name="e"><para>The <see cref="Exception"/> to publish.</para></param>
        protected override void PublishFailureEvent(string configurationName, Exception e)
        {
            Exception wrappedException = new ExceptionHandlingException(SR.UnableToLoadExceptionHandlers(configurationName, this.policyName), e);

            ExceptionUtility.LogHandlingException(this.policyName, wrappedException, null, e);
            throw new ExceptionHandlingException(SR.UnableToLoadExceptionHandlers(configurationName, this.policyName));
        }
示例#3
0
        private Exception ExecuteHandlerChain(Exception ex, Guid handlingInstanceID)
        {
            string    lastHandlerName   = String.Empty;
            Exception originalException = ex;

            try
            {
                IExceptionHandler[] handlers = this.factory.CreateExceptionHandlers(policyName, typeDataName);
                for (int i = 0; i < handlers.Length; i++)
                {
                    lastHandlerName = handlers[i].GetType().Name;
                    ex = handlers[i].HandleException(ex, policyName, handlingInstanceID);
                }
            }
            catch (Exception handlingException)
            {
                ExceptionUtility.LogHandlingException(
                    policyName,
                    new ExceptionHandlingException(SR.UnableToHandleException(lastHandlerName), handlingException),
                    ex,
                    originalException
                    );
                throw new ExceptionHandlingException(SR.UnableToHandleException(lastHandlerName));
            }

            return(ex);
        }
示例#4
0
 private Type GetExceptionType(ExceptionTypeData typeData, string policyName)
 {
     try
     {
         return(Type.GetType(typeData.TypeName, true));
     }
     catch (TypeLoadException e)
     {
         ExceptionUtility.LogHandlingException(policyName, null, null, e);
         ExceptionNotHandledEvent.Fire();
         throw new ExceptionHandlingException(SR.ExceptionUnknownExceptionTypeInConfiguration(typeData.TypeName), e);
     }
 }
示例#5
0
 /// <devdoc>
 /// Rethrows the given exception.  Placed in a seperate method for
 /// easier viewing in the stack trace.
 /// </devdoc>
 private void IntentionalRethrow(Exception chainException, Exception originalException)
 {
     if (chainException != null)
     {
         ExceptionHandledEvent.Fire();
         throw chainException;
     }
     else
     {
         Exception wrappedException = new ExceptionHandlingException(SR.ExceptionNullException);
         ExceptionUtility.LogHandlingException(policyName, wrappedException, chainException, originalException);
         throw wrappedException;
     }
 }
示例#6
0
 private static ExceptionPolicy GetExceptionPolicy(Exception exception, string policyName, ConfigurationContext configurationContext)
 {
     try
     {
         ExceptionPolicyFactory factory = new ExceptionPolicyFactory(configurationContext);
         return(factory.CreateExceptionPolicy(policyName, exception));
     }
     catch (ConfigurationException ex)
     {
         ExceptionUtility.LogHandlingException(policyName, ex, null, exception);
         ExceptionNotHandledEvent.Fire();
         throw new ExceptionHandlingException(ex.Message, ex);
     }
     catch (InvalidOperationException ex)
     {
         ExceptionUtility.LogHandlingException(policyName, ex, null, exception);
         ExceptionNotHandledEvent.Fire();
         throw new ExceptionHandlingException(ex.Message, ex);
     }
 }