예제 #1
0
        /// <summary>
        /// The main entry point into the Exception Handling Application Block.
        /// Handles the specified <see cref="Exception"/>
        /// object according to the given <paramref name="policyName"></paramref>.
        /// </summary>
        /// <param name="exceptionToHandle">An <see cref="Exception"/> object.</param>
        /// <param name="policyName">The name of the policy to handle.</param>
        /// <returns>
        /// Whether or not a rethrow is recommended.
        /// </returns>
        /// <example>
        /// The following code shows the usage of the
        /// exception handling framework.
        /// <code>
        /// try
        ///	{
        ///		DoWork();
        ///	}
        ///	catch (Exception e)
        ///	{
        ///		if (ExceptionPolicy.HandleException(e, name)) throw;
        ///	}
        /// </code>
        /// </example>
        public static bool HandleException(Exception exceptionToHandle, string policyName)
        {
            if (exceptionToHandle == null)
            {
                throw new ArgumentNullException("exceptionToHandle");
            }
            if (string.IsNullOrEmpty(policyName))
            {
                throw new ArgumentException(Resources.ExceptionStringNullOrEmpty);
            }

            ExceptionPolicyImpl policy = GetExceptionPolicy(exceptionToHandle, policyName);

            return(policy.HandleException(exceptionToHandle));
        }
예제 #2
0
        private static bool HandleException(Exception exceptionToHandle, string policyName, ExceptionPolicyFactory policyFactory)
        {
            ExceptionPolicyImpl policy = GetExceptionPolicy(exceptionToHandle, policyName, policyFactory);

            return(policy.HandleException(exceptionToHandle));
        }