/// <summary>
 /// Handles an Ensurance failure for the given constraint. Implementors
 /// should always call 
 /// <code>
 /// IEnsuranceResponsibilityChainLink handler = successor;
 /// if( successor != null) {
 ///     successor.Handle( constraint, message, args );
 /// }
 /// </code>
 /// So that the downstream handler can have a chance to process the
 /// failure.
 /// </summary>
 /// <exception cref="EnsuranceException">Always</exception>
 /// <param name="constraint">The constraint.</param>
 /// <param name="message">The message.</param>
 /// <param name="args">The args.</param>
 public override void Handle( Constraint constraint, string message, params object[] args )
 {
     try
     {
         MessageWriter messageWriter = new TextMessageWriter( new StringWriter( CultureInfo.CurrentCulture ) );
         constraint.WriteMessageTo( messageWriter );
         throw new EnsuranceException( messageWriter.ToString() );
     }
     finally
     {
         IEnsuranceResponsibilityChainLink handler = Successor;
         if ( handler != null )
         {
             handler.Handle( constraint, message, args );
         }
     }
 }
        /// <summary>
        /// Handles an Ensurance failure for the given constraint. Implementors
        /// should always call
        /// <code>
        /// IEnsuranceResponsibilityChainLink handler = successor;
        /// if( handler != null ) {
        ///     handler.Handle( constraint, message, args );
        /// }
        /// </code>
        /// So that the downstream handler can have a chance to process the
        /// failure.
        /// </summary>
        /// <param name="constraint">The constraint.</param>
        /// <param name="message">The message.</param>
        /// <param name="args">The args.</param>
        public void Handle( Constraint constraint, string message, params object[] args )
        {
            try
            {
                MessageWriter messagewriter = new TextMessageWriter();
                messagewriter.WriteLine();
                constraint.WriteMessageTo( messagewriter );
                messagewriter.Write( new StackTraceWriter().ToString() );

                string tmpMessage = String.Format( CultureInfo.CurrentCulture, "{0}{1}", message, messagewriter );

                switch ( _logger.DefaultLogSeverity )
                {
                    case LogSeverity.Debug:
                        _logger.Debug( tmpMessage, args );
                        break;
                    case LogSeverity.Info:
                        _logger.Info( tmpMessage, args );
                        break;
                    case LogSeverity.Warn:
                        _logger.Warn( tmpMessage, args );
                        break;
                    case LogSeverity.Error:
                        _logger.Error( tmpMessage, args );
                        break;
                    case LogSeverity.Fatal:
                        _logger.Fatal( tmpMessage, args );
                        break;
                }
            }
            finally
            {
                IEnsuranceResponsibilityChainLink handler = _successor;
                if ( handler != null )
                {
                    handler.Handle( constraint, message, args );
                }
            }
        }