<commit_before>package org.thinkinghub.gateway.oauth.controller;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.thinkinghub.gateway.oauth.exception.GatewayException;

import lombok.extern.slf4j.Slf4j;

@ControllerAdvice
@Slf4j
public class GlobalExceptionHandlingController {

	@ExceptionHandler({GatewayException.class})
	public String gatewayBusinessError(HttpServletRequest request, Exception exception){
		log.error("Request "+ request.getRequestURL() + " raised " + exception);
		return "gatewayerror";
	}
	
	@ExceptionHandler({SQLException.class})
	public String databaseError(HttpServletRequest request, Exception exception){
		log.error("Request "+ request.getRequestURL() + " raised " + exception);
		return "databaseerror";
	}
	
	@ExceptionHandler({IOException.class})
	public String IOError(HttpServletRequest request, Exception exception){
		log.error("Request "+ request.getRequestURL() + " raised " + exception);
		return "ioerror";<commit_msg>add method to handle exception from Spring (MissingServletRequestParameterException)<commit_after>package org.thinkinghub.gateway.oauth.controller;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.http.HttpServletRequest;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.thinkinghub.gateway.oauth.exception.GatewayException;

import lombok.extern.slf4j.Slf4j;

@ControllerAdvice
@Slf4j
public class GlobalExceptionHandlingController {

	@ExceptionHandler({Exception.class, RuntimeException.class})
	@ResponseStatus(value=HttpStatus.BAD_REQUEST)
	public String defaultError(HttpServletRequest request, Exception exception){
		log.error("Request "+ request.getRequestURL() + " raised " + exception);
		return "An error happened";
	}
	
	@ExceptionHandler({GatewayException.class})
	public String gatewayError(HttpServletRequest request, Exception exception){
		log.error("Request "+ request.getRequestURL() + " raised " + exception);
		return "gatewayerror";
	}
	
	@ExceptionHandler({MissingServletRequestParameterException.class})
	@ResponseStatus(value=HttpStatus.BAD_REQUEST)
	public String requestParamError(HttpServletRequest request, Exception exception){
		log.error("Request "+ request.getRequestURL() + " raised " + exception);
		return "Your request is missing parameter(s)";
	}
	
	@ExceptionHandler({SQLException.class})
	public String databaseError(HttpServletRequest request, Exception exception){
		log.error("Request "+ request.getRequestURL() + " raised " + exception);
		return "databaseerror";
	}
	
	@ExceptionHandler({IOException.class})
	public String ioError(HttpServletRequest request, Exception exception){
		log.error("Request "+ request.getRequestURL() + " raised " + exception);
		return "ioerror";
{'fraction_non_alphanumeric': 0.10630291627469426, 'fraction_numerical': 0.0018814675446848542, 'mean_word_length': 7.137755102040816, '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': '3878481', 'n_tokens_mistral': 867, 'n_tokens_neox': 840, 'n_words': 167}