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); }
public ActionExceptionHandler(ILog logger, IExceptionMessageFormatter exceptionMessageFormatter) { _logger = logger; _exceptionMessageFormatter = exceptionMessageFormatter; }
public DbExceptionHandler( IExceptionMessageFormatter exceptionMessageFormatter ) { _exceptionMessageFormatter = exceptionMessageFormatter; }
public ExceptionMessageFormatterFactoryTestFixtures WithExceptionFormatter(IExceptionMessageFormatter formatter) { ExceptionMessageFormatters.Add(formatter); return(this); }