<commit_before>require 'dredd_hooks/definitions'
require 'dredd_hooks/errors'
require 'dredd_hooks/runner'

module DreddHooks

  class Server
    class EventsHandler

      attr_reader :events, :runner
      private :events, :runner

      def initialize(events=EVENTS, runner=Runner.instance)
        @events = events
        @runner = runner
      end

      def handle(event, transaction)

        begin
          events.fetch(event.to_sym).each do |hook_name|
            begin
              transaction = runner.send("run_#{hook_name}_hooks_for_transaction", transaction)
            rescue NoMethodError
              raise UnknownHookError.new(hook_name)
            end
          end
        rescue KeyError => error
        end

        transaction
      end
    end
  end
end
<commit_msg>Minor refactor do not suppress exception<commit_after>require 'dredd_hooks/definitions'
require 'dredd_hooks/errors'
require 'dredd_hooks/runner'

module DreddHooks

  class Server
    class EventsHandler

      attr_reader :events, :runner
      private :events, :runner

      def initialize(events=EVENTS, runner=Runner.instance)
        @events = events
        @runner = runner
      end

      def handle(event, transaction)

         events.fetch(event.to_sym, []).each do |hook_name|
         begin
           transaction = runner.send("run_#{hook_name}_hooks_for_transaction", transaction)
          rescue NoMethodError
            raise UnknownHookError.new(hook_name)
          end
        end

        transaction
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.06889890534449453, 'fraction_numerical': 0.0, 'mean_word_length': 2.334763948497854, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '3819195', 'n_tokens_mistral': 439, 'n_tokens_neox': 437, 'n_words': 105}