Project

General

Profile

1
package eu.dnetlib.uoaadmintools.handlers;
2

    
3
import eu.dnetlib.uoaadmintoolslibrary.responses.ExceptionResponse;
4

    
5
import eu.dnetlib.uoaadmintoolslibrary.handlers.InvalidReCaptchaException;
6
import org.apache.log4j.Logger;
7
import org.springframework.http.HttpStatus;
8
import org.springframework.http.ResponseEntity;
9
import org.springframework.web.bind.MissingServletRequestParameterException;
10
import org.springframework.web.bind.annotation.ControllerAdvice;
11
import org.springframework.web.bind.annotation.ExceptionHandler;
12

    
13
@ControllerAdvice
14
public class ExceptionsHandler {
15
    private final Logger log = Logger.getLogger(this.getClass());
16

    
17
//    @ExceptionHandler(MissingServletRequestParameterException.class)
18
//    public ResponseEntity<ExceptionResponse> invalidInput(Exception ex) {
19
//        ExceptionResponse response = new ExceptionResponse();
20
//        response.setErrorCode("Validation Error");
21
//        response.setErrorMessage("Invalid inputs.");
22
//        response.setErrors(ex.getMessage());
23
//        log.debug("invalidInput exception");
24
//
25
//        return new ResponseEntity<ExceptionResponse>(response, HttpStatus.BAD_REQUEST);
26
//    }
27
//    @ExceptionHandler(ContentNotFoundException2.class)
28
//    public ResponseEntity<ExceptionResponse> contentNotFound(Exception ex) {
29
//        ExceptionResponse response = new ExceptionResponse();
30
//        response.setErrorCode("No content found");
31
//        response.setErrorMessage(ex.getMessage());
32
//        response.setErrors(ex.getMessage());
33
//        log.debug("contentNotFound exception" + response.getErrorCode()+ " "+response.getErrorMessage());
34
//        return new ResponseEntity<ExceptionResponse>(response, HttpStatus.NOT_FOUND);
35
//    }
36
//    @ExceptionHandler(NullPointerException.class)
37
//    public ResponseEntity<ExceptionResponse> nullPointerException(Exception ex) {
38
//        ExceptionResponse response = new ExceptionResponse();
39
//        response.setErrorCode("Null pointer Exception");
40
//        response.setErrorMessage("Null pointer Exception");
41
//        response.setErrors(ex.getMessage());
42
//        log.debug("nullPointerException exception");
43
//        return new ResponseEntity<ExceptionResponse>(response, HttpStatus.BAD_REQUEST);
44
//    }
45
//    @ExceptionHandler(InvalidReCaptchaException.class)
46
//    public ResponseEntity<ExceptionResponse> invalidReCaptchaException(Exception ex) {
47
//        ExceptionResponse response = new ExceptionResponse();
48
//        response.setErrorCode("Invalid ReCaptcha Exception");
49
//        response.setErrorMessage("Invalid ReCaptcha Exception");
50
//        response.setErrors(ex.getMessage());
51
//        log.debug("invalidReCaptchaException exception");
52
//        return new ResponseEntity<ExceptionResponse>(response, HttpStatus.BAD_REQUEST);
53
//    }
54
}
(4-4/4)