Esempio n. 1
0
 /// <summary>
 /// Chains the exceptions.
 /// </summary>
 /// <param name="message">The message of the new exception.</param>
 /// <param name="chain">The chain to "inner link" everything.</param>
 /// <returns>A new rule violation exception with the inner chains if necessary.</returns>
 public static RuleViolationException ChainException(string message, RuleViolationException chain)
 {
     if (chain == null)
     {
         return(new RuleViolationException(message));
     }
     return(new RuleViolationException(message, chain));
 }
Esempio n. 2
0
        /// <summary>
        /// Chains the exceptions.
        /// </summary>
        /// <param name="newException">The new exception.</param>
        /// <param name="chain">The chain to "inner link" everything.</param>
        /// <returns>A new rule violation exception with the inner chains if necessary.</returns>
        public static RuleViolationException ChainException(RuleViolationException newException, RuleViolationException chain)
        {
            // if there is nothing to chain return the new exception
            if (chain == null)
            {
                return(newException);
            }

            // if there are no new inner exceptions, simply return the chain
            if (newException.InnerException == null)
            {
                return(ChainException(newException.Message, chain));
            }
            else             // recurse through the new exception chain to link up the two chains
            {
                RuleViolationException newChain = ChainException(newException.InnerException as RuleViolationException, chain);
                return(ChainException(newException.Message, newChain));
            }
        }