<commit_before>class BaseToolsController < ApplicationController
  def all_names
    names = {base_tool_names: KalibroGem::Entities::BaseTool.all_names}

    respond_to do |format|
      format.html { render json: names }
      format.json { render json: names }
    end
  end

  def get
    base_tool = KalibroGem::Entities::BaseTool.find_by_name(params[:name]).to_hash

    respond_to do |format|
      format.json { render json: base_tool }
    end
  end
end<commit_msg>Get BaseTool error handling<commit_after>class BaseToolsController < ApplicationController
  def all_names
    names = {base_tool_names: KalibroGem::Entities::BaseTool.all_names}

    respond_to do |format|
      format.html { render json: names }
      format.json { render json: names }
    end
  end

  def get
    begin
      base_tool = KalibroGem::Entities::BaseTool.find_by_name(params[:name])
    rescue KalibroGem::Errors::RecordNotFound
      base_tool = {error: 'RecordNotFound'}
    end

    respond_to do |format|
      if base_tool.is_a?(KalibroGem::Entities::BaseTool)
        format.json { render json: base_tool.to_hash }
      else
        format.json { render json: base_tool, status: :unprocessable_entity }
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.08713355048859935, 'fraction_numerical': 0.0, 'mean_word_length': 3.420863309352518, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '7473628', 'n_tokens_mistral': 391, 'n_tokens_neox': 390, 'n_words': 89}