<commit_before>class Errors::Show < Lucky::ErrorAction
  def handle_error(error : JSON::ParseException)
    if json?
      json({error: "There was a problem parsing the JSON. Please check that it is formed correctly"}, status: 400)
    else
      head status: 400
    end
  end

  def handle_error(error : Exception)
    head status: 500
  end
end<commit_msg>Print stacktrace to STDERR (#117)<commit_after>class Errors::Show < Lucky::ErrorAction
  def handle_error(error : JSON::ParseException)
    if json?
      json({error: "There was a problem parsing the JSON. Please check that it is formed correctly"}, status: 400)
    else
      head status: 400
    end
  end

  def handle_error(error : Exception)
    error.inspect_with_backtrace(STDERR)

    if json?
      json({error: "An unexpected error occured"}, status: 500)
    else
      response.status_code = 500
      render_text "Something went wrong"
    end
  end
end
{'fraction_non_alphanumeric': 0.08306364617044229, 'fraction_numerical': 0.025889967637540454, 'mean_word_length': 3.3773584905660377, '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': '818092', 'n_tokens_mistral': 300, 'n_tokens_neox': 266, 'n_words': 96}