<commit_before>require "ecr"

class Orion::Handlers::Exceptions
  include HTTP::Handler

  def call(cxt : HTTP::Server::Context)
    begin
      call_next(cxt)
    rescue e
      response = cxt.response
      status_code = response.status_code
      response.reset
      response.status_code = e.is_a?(RoutingError) ? 404 : 500
      {% if flag?(:release) %}
        message = e.is_a?(RoutingError) ? "The page you were looking for doesn't exist." : "We're sorry, but something went wrong."
        page_title = "#{message} (#{response.status_code})"
        subtext = e.is_a?(RoutingError) ? "You may have mistyped the address or the page may have moved." : "Please report this error to the application owner for assistance."
        response.headers["Content-Type"] = "text/html"
        ECR.embed "#{__DIR__}/../error_page.html.ecr", response
      {% else %}
        response.print ExceptionPage.for_runtime_exception(cxt, e).to_s
      {% end %}
    end
  end
end
<commit_msg>page title last<commit_after>require "ecr"

class Orion::Handlers::Exceptions
  include HTTP::Handler

  def call(cxt : HTTP::Server::Context)
    begin
      call_next(cxt)
    rescue e
      response = cxt.response
      status_code = response.status_code
      response.reset
      response.status_code = e.is_a?(RoutingError) ? 404 : 500
      {% if flag?(:release) %}
        message = e.is_a?(RoutingError) ? "The page you were looking for doesn't exist." : "We're sorry, but something went wrong."
        subtext = e.is_a?(RoutingError) ? "You may have mistyped the address or the page may have moved." : "Please report this error to the application owner for assistance."
        page_title = "#{message} (#{response.status_code})"
        response.headers["Content-Type"] = "text/html"
        ECR.embed "#{__DIR__}/../error_page.html.ecr", response
      {% else %}
        response.print ExceptionPage.for_runtime_exception(cxt, e).to_s
      {% end %}
    end
  end
end

{'fraction_non_alphanumeric': 0.12118126272912423, 'fraction_numerical': 0.006109979633401222, 'mean_word_length': 3.051546391752577, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6697589', 'n_tokens_mistral': 621, 'n_tokens_neox': 604, 'n_words': 162}