<commit_before>class BreadcrumbBakery
  include Rails.application.routes.url_helpers

  def initialize(current_uri)
    @breadcrumbs = []
    @recognized_path = Rails.application.routes.recognize_path(current_uri)
    create_breadcrumbs
  rescue
  end

  def create_breadcrumbs
    partial_recognized_path = {}

    @recognized_path.each do |key, value|
      partial_recognized_path.merge!({key => value})
      key_string = key.to_s

      if key_string == 'id'
        add_tailing_breadcrumbs

      elsif key_string.end_with?('_id')
        controller_name = key_string[0..-4]

        add_breadcrumb(controller_name.pluralize,
          custom_url_for_controller(partial_recognized_path, controller_name, 'index'))

        add_breadcrumb(recognize_instance_name(controller_name, partial_recognized_path),
          custom_url_for_controller(partial_recognized_path, controller_name, 'show'))
      end
    end

    add_trivial_breadcrumb if @breadcrumbs == []
  end<commit_msg>integrate senseful exception handling for failing `regcognize_path`<commit_after>class BreadcrumbBakery
  include Rails.application.routes.url_helpers

  def initialize(current_uri)
    @breadcrumbs = []
    @recognized_path = Rails.application.routes.recognize_path(current_uri)
    create_breadcrumbs
  rescue
    @breadcrumbs = []
  end

  def create_breadcrumbs
    partial_recognized_path = {}

    @recognized_path.each do |key, value|
      partial_recognized_path.merge!({key => value})
      key_string = key.to_s

      if key_string == 'id'
        add_tailing_breadcrumbs

      elsif key_string.end_with?('_id')
        controller_name = key_string[0..-4]

        add_breadcrumb(controller_name.pluralize,
          custom_url_for_controller(partial_recognized_path, controller_name, 'index'))

        add_breadcrumb(recognize_instance_name(controller_name, partial_recognized_path),
          custom_url_for_controller(partial_recognized_path, controller_name, 'show'))
      end
    end

    add_trivial_breadcrumb if @breadcrumbs == []
  end
{'fraction_non_alphanumeric': 0.08129285014691479, 'fraction_numerical': 0.0019588638589618022, 'mean_word_length': 3.9347826086956523, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4017960', 'n_tokens_mistral': 660, 'n_tokens_neox': 640, 'n_words': 98}