private static IExceptionMessageFormatter GetExceptionFormatter(Exception exception)
        {
            IExceptionMessageFormatter formatter = null;

            if (exception == null)
            {
                return(GeneralExceptionFormatter);
            }

            var exceptionType = exception.GetType();

            while (formatter == null)
            {
                // convert to dictionary
                formatter = ExceptionFormatters.FirstOrDefault(ef => ef.SupportedException == exceptionType);

                if (formatter != null)
                {
                    continue;
                }

                if (exceptionType.BaseType == null)
                {
                    return(GeneralExceptionFormatter);
                }

                exceptionType = exceptionType.BaseType;
            }

            return(formatter);
        }
Пример #2
0
 public ActionExceptionHandler(ILog logger, IExceptionMessageFormatter exceptionMessageFormatter)
 {
     _logger = logger;
     _exceptionMessageFormatter = exceptionMessageFormatter;
 }
 public ActionExceptionHandler(ILog logger, IExceptionMessageFormatter exceptionMessageFormatter)
 {
     _logger = logger;
     _exceptionMessageFormatter = exceptionMessageFormatter;
 }
Пример #4
0
 public DbExceptionHandler( IExceptionMessageFormatter exceptionMessageFormatter )
 {
     _exceptionMessageFormatter = exceptionMessageFormatter;
 }
 public ExceptionMessageFormatterFactoryTestFixtures WithExceptionFormatter(IExceptionMessageFormatter formatter)
 {
     ExceptionMessageFormatters.Add(formatter);
     return(this);
 }