Пример #1
0
        /// <summary>
        /// Handles the exception.
        /// </summary>
        /// <param name="exceptionToHandle">The exception to handle.</param>
        /// <param name="policyName">Name of the policy.</param>
        public void HandleException(Exception exceptionToHandle, PolicyNameType policyName = PolicyNameType.ExceptionShielding)
        {
            Exception newException;

            Logger.Error("An error occurred while processing your request: ", exceptionToHandle);
            bool reThrow = _exceptionManager.HandleException(exceptionToHandle, GetPolicyName(policyName), out newException);

            if (reThrow)
            {
                throw newException;
            }
        }
Пример #2
0
        /// <summary>
        /// Gets the name of the policy.
        /// </summary>
        /// <param name="policyName">Name of the policy.</param>
        /// <returns></returns>
        private string GetPolicyName(PolicyNameType policyName)
        {
            string returnedPolicyName;

            switch (policyName)
            {
            case PolicyNameType.ExceptionShielding:
                returnedPolicyName = C.ExceptionPolicy.Names.ExceptionShielding;
                break;

            default:
                returnedPolicyName = C.ExceptionPolicy.Names.ExceptionReplacing;
                break;
            }
            return(returnedPolicyName);
        }
Пример #3
0
 /// <summary>
 /// Processes the specified action.
 /// </summary>
 /// <typeparam name="TResult">The type of the result.</typeparam>
 /// <param name="action">The action.</param>
 /// <param name="policyName">Name of the policy.</param>
 /// <returns></returns>
 public TResult Process <TResult>(Func <TResult> action, PolicyNameType policyName = PolicyNameType.ExceptionShielding)
 {
     return(_exceptionManager.Process <TResult>(action, GetPolicyName(policyName)));
 }
Пример #4
0
 /// <summary>
 /// Processes the specified action.
 /// </summary>
 /// <param name="action">The action.</param>
 /// <param name="policyName">Name of the policy.</param>
 public void Process(Action action, PolicyNameType policyName = PolicyNameType.ExceptionShielding)
 {
     _exceptionManager.Process(action, GetPolicyName(policyName));
 }
Пример #5
0
 /// <summary>
 /// Does not process the specified action.
 /// </summary>
 /// <param name="action">The action.</param>
 /// <param name="policyName">Name of the policy.</param>
 public void Process(Action action, PolicyNameType policyName = PolicyNameType.ExceptionShielding)
 {
     // Do nothing
 }
Пример #6
0
 /// <summary>
 /// Does not process the specified action.
 /// Method has no implementation.
 /// </summary>
 /// <typeparam name="TResult">The type of the result.</typeparam>
 /// <param name="action">The action.</param>
 /// <param name="policyName">Name of the policy.</param>
 /// <returns>default(TResult)</returns>
 public TResult Process <TResult>(Func <TResult> action, PolicyNameType policyName = PolicyNameType.ExceptionShielding)
 {
     return(default(TResult));
 }
Пример #7
0
 /// <summary>
 /// Does not Handle the exception.
 /// Method has no implementation.
 /// </summary>
 /// <param name="exceptionToHandle">The exception to handle.</param>
 /// <param name="policyName">Name of the policy.</param>
 public void HandleException(Exception exceptionToHandle, PolicyNameType policyName = PolicyNameType.ExceptionShielding)
 {
     // Do nothing
 }