private void ConfigureExceptionHandling()
{
var configurationSource = new DictionaryConfigurationSource();
var builder = new ConfigurationSourceBuilder();
builder
.ConfigureExceptionHandling()
.GivenPolicyWithName(DefaultPolicy)
.ForExceptionType<DeleteConstraintException>()
.HandleCustom<HttpErrorExceptionHandler>()
.ThenThrowNewException()
.ForExceptionType<BusinessValidationException>()
.HandleCustom<BusinessValidationExceptionHandler>()
.ThenThrowNewException()
.ForExceptionType<BusinessException>()
.HandleCustom<HttpErrorExceptionHandler>()
.ThenThrowNewException()
.ForExceptionType<Exception>()
.LogToCategory("General")
.WithSeverity(TraceEventType.Critical)
.UsingExceptionFormatter<TextExceptionFormatter>()
.HandleCustom(
typeof(HttpErrorExceptionHandler),
new NameValueCollection
{
{ HttpErrorExceptionHandler.StatusCodeKey, HttpStatusCode.InternalServerError.ToString("G") },
{ HttpErrorExceptionHandler.MessageKey, "An error has occurred while consuming this service. Please contact your administrator for more information." },
{ HttpErrorExceptionHandler.AppendHandlingIdKey, bool.TrueString }
})
.ThenThrowNewException();
builder.UpdateConfigurationWithReplace(configurationSource);
var configurator = new UnityContainerConfigurator(this.Container);
EnterpriseLibraryContainer.ConfigureContainer(configurator, configurationSource);
}