private static ExceptionPolicyImpl GetExceptionPolicy(Exception exception, string policyName) { try { return(EnterpriseLibraryContainer.Current.GetInstance <ExceptionPolicyImpl>(policyName)); } catch (ActivationException configurationException) { try { DefaultExceptionHandlingEventLogger logger = EnterpriseLibraryContainer.Current.GetInstance <DefaultExceptionHandlingEventLogger>(); logger.LogConfigurationError(configurationException, policyName); } catch { } throw; } catch (Exception ex) { try { string exceptionMessage = ExceptionUtility.FormatExceptionHandlingExceptionMessage(policyName, ex, null, exception); DefaultExceptionHandlingEventLogger logger = EnterpriseLibraryContainer.Current.GetInstance <DefaultExceptionHandlingEventLogger>(); logger.LogInternalError(policyName, exceptionMessage); } catch { } throw new ExceptionHandlingException(ex.Message, ex); } }
private static ExceptionPolicyImpl GetExceptionPolicy(Exception exception, string policyName, ExceptionPolicyFactory factory) { try { return(factory.Create(policyName)); } catch (ConfigurationErrorsException configurationException) { try { DefaultExceptionHandlingEventLogger logger = EnterpriseLibraryFactory.BuildUp <DefaultExceptionHandlingEventLogger>(); logger.LogConfigurationError(configurationException, policyName); } catch { } throw; } catch (Exception ex) { try { string exceptionMessage = ExceptionUtility.FormatExceptionHandlingExceptionMessage(policyName, ex, null, exception); DefaultExceptionHandlingEventLogger logger = EnterpriseLibraryFactory.BuildUp <DefaultExceptionHandlingEventLogger>(); logger.LogInternalError(policyName, exceptionMessage); } catch { } throw new ExceptionHandlingException(ex.Message, ex); } }