<commit_before>﻿using System;
using System.Collections.Generic;

namespace Regalo.Core
{
    public class EventBus : MessageProcessorBase, IEventBus
    {
        private readonly ILogger _logger;

        public EventBus(ILogger logger) 
            : base(logger)
        {
            if (logger == null) throw new ArgumentNullException("logger");
            _logger = logger;
        }

        public void Publish<TEvent>(TEvent evt)
        {
            var eventType = evt.GetType();

            try
            {
                HandleMessage(evt, typeof(IEventHandler<>));
            }
            catch (Exception e)
            {
                if (IsRetryableException(evt, e))
                {
                    _logger.Error(this, e, "Failed to handle {0}, allowing retryable exception to propagate...");
                    throw;
                }

                if (eventType != typeof(object))
                {
                    var failedEvent = EventHandlingFailedEvent.Create(evt, e);
                    _logger.Error(this, e, "Failed to handle {0}, publishing {1}...", evt, failedEvent);
                    HandleMessage(failedEvent, typeof(IEventHandler<>));
                }
                else<commit_msg>Fixed logging bug - missing format argument.<commit_after>﻿using System;
using System.Collections.Generic;

namespace Regalo.Core
{
    public class EventBus : MessageProcessorBase, IEventBus
    {
        private readonly ILogger _logger;

        public EventBus(ILogger logger) 
            : base(logger)
        {
            if (logger == null) throw new ArgumentNullException("logger");
            _logger = logger;
        }

        public void Publish<TEvent>(TEvent evt)
        {
            var eventType = evt.GetType();

            try
            {
                HandleMessage(evt, typeof(IEventHandler<>));
            }
            catch (Exception e)
            {
                if (IsRetryableException(evt, e))
                {
                    _logger.Error(this, e, "Failed to handle {0}, allowing retryable exception to propagate...", evt);
                    throw;
                }

                if (eventType != typeof(object))
                {
                    var failedEvent = EventHandlingFailedEvent.Create(evt, e);
                    _logger.Error(this, e, "Failed to handle {0}, publishing {1}...", evt, failedEvent);
                    HandleMessage(failedEvent, typeof(IEventHandler<>));
                }
                else
{'fraction_non_alphanumeric': 0.09367588932806324, 'fraction_numerical': 0.0023715415019762848, 'mean_word_length': 1.4862475442043221, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4702878', 'n_tokens_mistral': 629, 'n_tokens_neox': 613, 'n_words': 155}