Beispiel #1
0
        /// <summary>
        /// Creates a new <see cref="ExceptionCallHandler"/> that processses exceptions
        /// using the given exception policy name, as defined in <paramref name="configurationSource"/>.
        /// </summary>
        /// <param name="exceptionPolicyName">Exception policy name.</param>
        /// <param name="configurationSource">Configuration source defining the exception handling policy.</param>
        public ExceptionCallHandler(string exceptionPolicyName, IConfigurationSource configurationSource)
        {
            this.exceptionPolicyName = exceptionPolicyName;
            ExceptionPolicyFactory policyFactory = new ExceptionPolicyFactory(configurationSource);

            exceptionPolicy = policyFactory.Create(exceptionPolicyName);
        }
        /// <summary>
        /// This method handle the policy by enterprise library exception handling block
        /// </summary>
        /// <param name="policyName">Policy Name.</param>
        /// <param name="ex">Exception</param>
        /// <returns></returns>
        public bool Handle(string policyName, ref Exception ex)
        {
            bool rethrow = false;
            ExceptionPolicyImpl exceptImpl = _exceptionPolicyFactory.Create(policyName);

            rethrow = exceptImpl.HandleException(ex);
            if (rethrow)
            {
                throw ex;
            }
            return(rethrow);
        }