/// <summary> /// Logs exceptions encountered by the ClearView application. /// </summary> /// <param name="exception"></param> protected string LogException(Exception exception) { // Add information about the current web request AddExceptionInformation(exception); // Create GUID for this exception (for tracking purposes) System.Guid exceptionGUID = System.Guid.NewGuid(); // Log error LoggingExceptionHandler loggingExceptionHandler = new LoggingExceptionHandler(); loggingExceptionHandler.HandleException(exception, exceptionGUID); // Email error string dsn = ConfigurationManager.ConnectionStrings[ConfigurationManager.AppSettings["DSN"]].ConnectionString; int intEnvironment = Int32.Parse(ConfigurationManager.AppSettings["Environment"]); Variables variables = new Variables(intEnvironment); Functions oFunction = new Functions(0, dsn, intEnvironment); string strEMailIdsTO = oFunction.GetGetEmailAlertsEmailIds("EMAILGRP_DEVELOPER_ERROR"); MessageExceptionHandler messageExceptionHandler = new MessageExceptionHandler(variables.FromEmail(), strEMailIdsTO, variables.SmtpServer()); messageExceptionHandler.HandleException(exception, exceptionGUID); if (intEnvironment == (int)CurrentEnvironment.CORPDMN || intEnvironment == (int)CurrentEnvironment.PNCNT_PROD) { messageExceptionHandler.Email(); } return(messageExceptionHandler.Message); }
public void Message_Handled_Exception_Throws_Exception() { var fixture = new Fixture().Customize(new AutoNSubstituteCustomization()); IReceiveMessagesError error = fixture.Create <ReceiveMessagesErrorWillCrash>(); fixture.Inject(error); var test = new MessageExceptionHandler(error, Substitute.For <ILogger>()); var message = fixture.Create <IReceivedMessageInternal>(); var context = fixture.Create <IMessageContext>(); var exception = new Exception(); Assert.Throws <DotNetWorkQueueException>( delegate { test.Handle(message, context, exception); }); }