19 lines
848 B
Java
19 lines
848 B
Java
package eu.dnetlib.validatorapi.exceptions;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.context.request.WebRequest;
|
|
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
|
|
|
|
@ControllerAdvice
|
|
public class ExceptionHandler extends ResponseEntityExceptionHandler {
|
|
|
|
@ResponseBody
|
|
@org.springframework.web.bind.annotation.ExceptionHandler(value = {ValidationException.class})
|
|
protected ResponseEntity<ErrorMessage> handleValidationError(RuntimeException exception, WebRequest request) {
|
|
return new ResponseEntity(new ErrorMessage(exception.getMessage()), HttpStatus.BAD_REQUEST);
|
|
}
|
|
}
|