コード例 #1
0
        /// <summary>
        /// Logs an error in log for the application
        /// </summary>
        public void Log(Error error)
        {
            if (error == null)
            {
                throw new ArgumentNullException("error");
            }

            // if we're in a retry state, log directly to the queue
            if (_isInRetry)
            {
                QueueError(error);
                ErrorEmailer.SendMail(error);
                return;
            }
            try
            {
                using (new TransactionScope(TransactionScopeOption.Suppress))
                {
                    LogError(error);
                }
                ErrorEmailer.SendMail(error);
            }
            catch (Exception ex)
            {
                _retryException = ex;
                // if we fail to write the error to the store, queue it for re-writing
                QueueError(error);
            }
        }
コード例 #2
0
        /// <summary>
        /// Logs an error in log for the application
        /// </summary>
        public void Log(Error error)
        {
            if (error == null)
            {
                throw new ArgumentNullException(nameof(error));
            }

            // Track the GUID we made vs. what the store returns. If it's different, it's a dupe.
            var originalGuid = error.GUID;

            // if we're in a retry state, log directly to the queue
            if (_isInRetry)
            {
                QueueError(error);
                if (originalGuid != error.GUID)
                {
                    error.IsDuplicate = true;
                }
                ErrorEmailer.SendMail(error);
                return;
            }
            try
            {
                using (new TransactionScope(TransactionScopeOption.Suppress))
                {
                    LogError(error);
                }
                if (originalGuid != error.GUID)
                {
                    error.IsDuplicate = true;
                }
                ErrorEmailer.SendMail(error);
            }
            catch (Exception ex)
            {
                _retryException = ex;
                // if we fail to write the error to the store, queue it for re-writing
                QueueError(error);
            }
        }