<commit_before>package controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;

@Controller
public class ErrorsController {
  /**
   * .
   * @param httpRequest .
   * @return .
   */
  @RequestMapping(value = "errors")
  public String renderErrorPage(HttpServletRequest httpRequest, Model model) {

    Integer httpErrorCode = getErrorCode(httpRequest);

    Throwable throwable = (Throwable) httpRequest.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
    if (httpErrorCode == 500) {
      model.addAttribute("stacktrace", throwable.getStackTrace());
      model.addAttribute("message", throwable.getMessage());
    }

    String errorPage = httpErrorCode.toString();
    return errorPage;
  }

  /**
   * return error code of request.
   * @param httpRequest .
   * @return error code
   */
  private Integer getErrorCode(HttpServletRequest httpRequest) {
    return (Integer) httpRequest
        .getAttribute("javax.servlet.error.status_code");
  }
}<commit_msg>[refacto] small fixes<commit_after>package controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;

@Controller
public class ErrorsController {
  /**
   * .
   * @param httpRequest .
   * @return .
   */
  @RequestMapping(value = "errors")
  public String renderErrorPage(HttpServletRequest httpRequest, Model model) {

    Integer httpErrorCode = getErrorCode(httpRequest);

    Throwable throwable = (Throwable) httpRequest.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
    if (httpErrorCode == 500) { //TODO add debug var
      model.addAttribute("stacktrace", throwable.getStackTrace());
      model.addAttribute("message", throwable.getMessage());
    }

    String errorPage = httpErrorCode.toString();
    return errorPage;
  }

  /**
   * return error code of request.
   * @param httpRequest .
   * @return error code
   */
  private Integer getErrorCode(HttpServletRequest httpRequest) {
    return (Integer) httpRequest
        .getAttribute("javax.servlet.error.status_code");
  }
}
{'fraction_non_alphanumeric': 0.10624734381640459, 'fraction_numerical': 0.0025499362515937103, 'mean_word_length': 4.266219239373601, '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': '5317137', 'n_tokens_mistral': 640, 'n_tokens_neox': 640, 'n_words': 134}