<commit_before>package uk.ac.ebi.quickgo.rest;

import uk.ac.ebi.quickgo.rest.search.RetrievalException;
import uk.ac.ebi.quickgo.rest.service.ServiceConfigException;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * Handler responsible for returning error responses with a meaningful messages to the REST client.
 *
 * @author <NAME>
 */
@ControllerAdvice
public class ResponseExceptionHandler {
    @ExceptionHandler({IllegalStateException.class, RetrievalException.class, ServiceConfigException.class})
    protected ResponseEntity<ErrorInfo> handleInternalServer(RuntimeException ex, HttpServletRequest request) {
        ErrorInfo error = new ErrorInfo(request.getRequestURL().toString(), ex.getMessage());
        return new ResponseEntity<>(error, HttpStatus.INTERNAL_SERVER_ERROR);
    }

    @ExceptionHandler(IllegalArgumentException.class)
    protected ResponseEntity<ErrorInfo> handleBadRequest(RuntimeException ex, HttpServletRequest request) {
        ErrorInfo error = new ErrorInfo(request.getRequestURL().toString(), ex.getMessage());
        return new ResponseEntity<>(error, HttpStatus.BAD_REQUEST);
    }

    @ExceptionHandler(ParameterException.class)<commit_msg>Fix typo in Javadoc.<commit_after>package uk.ac.ebi.quickgo.rest;

import uk.ac.ebi.quickgo.rest.search.RetrievalException;
import uk.ac.ebi.quickgo.rest.service.ServiceConfigException;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * Handler responsible for returning error responses with meaningful messages to the REST client.
 *
 * @author <NAME>
 */
@ControllerAdvice
public class ResponseExceptionHandler {
    @ExceptionHandler({IllegalStateException.class, RetrievalException.class, ServiceConfigException.class})
    protected ResponseEntity<ErrorInfo> handleInternalServer(RuntimeException ex, HttpServletRequest request) {
        ErrorInfo error = new ErrorInfo(request.getRequestURL().toString(), ex.getMessage());
        return new ResponseEntity<>(error, HttpStatus.INTERNAL_SERVER_ERROR);
    }

    @ExceptionHandler(IllegalArgumentException.class)
    protected ResponseEntity<ErrorInfo> handleBadRequest(RuntimeException ex, HttpServletRequest request) {
        ErrorInfo error = new ErrorInfo(request.getRequestURL().toString(), ex.getMessage());
        return new ResponseEntity<>(error, HttpStatus.BAD_REQUEST);
    }

    @ExceptionHandler(ParameterException.class)
{'fraction_non_alphanumeric': 0.09598140152773164, 'fraction_numerical': 0.0, 'mean_word_length': 5.940092165898617, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '1921681', 'n_tokens_mistral': 773, 'n_tokens_neox': 770, 'n_words': 155}