Search in sources :

Example 1 with ErrorResponse

use of uk.ac.ebi.spot.goci.curation.dto.ErrorResponse in project goci by EBISPOT.

the class ExceptionHandlerAdvice method handleResourceNotFound.

@ExceptionHandler(ResourceNotFoundException.class)
public ResponseEntity<ErrorResponse> handleResourceNotFound(ResourceNotFoundException ex, HttpServletRequest req) {
    ErrorResponse error = ErrorResponse.basicResponse(HttpStatus.NOT_FOUND, ex, req, dateFormat);
    log.error(error.toString());
    return new ResponseEntity<>(error, HttpStatus.NOT_FOUND);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ErrorResponse(uk.ac.ebi.spot.goci.curation.dto.ErrorResponse) ResponseEntityExceptionHandler(org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler)

Example 2 with ErrorResponse

use of uk.ac.ebi.spot.goci.curation.dto.ErrorResponse in project goci by EBISPOT.

the class ExceptionHandlerAdvice method handleDataIntegrityException.

@ExceptionHandler(DataIntegrityException.class)
public ResponseEntity<ErrorResponse> handleDataIntegrityException(DataIntegrityException ex, HttpServletRequest req) {
    ErrorResponse error = ErrorResponse.basicResponse(HttpStatus.CONFLICT, ex, req, dateFormat);
    log.error(error.toString());
    return new ResponseEntity<>(error, HttpStatus.NOT_FOUND);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ErrorResponse(uk.ac.ebi.spot.goci.curation.dto.ErrorResponse) ResponseEntityExceptionHandler(org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler)

Example 3 with ErrorResponse

use of uk.ac.ebi.spot.goci.curation.dto.ErrorResponse in project goci by EBISPOT.

the class ExceptionHandlerAdvice method handleFileUploadException.

@ExceptionHandler(FileValidationException.class)
public ResponseEntity<ErrorResponse> handleFileUploadException(FileValidationException ex, HttpServletRequest req) {
    ErrorResponse error = ErrorResponse.basicResponse(HttpStatus.BAD_REQUEST, ex, req, dateFormat);
    ErrorResponse response = ErrorResponse.hibernateValidationResponse(error, ex.getBindingResult());
    log.error(response.toString());
    return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ErrorResponse(uk.ac.ebi.spot.goci.curation.dto.ErrorResponse) ResponseEntityExceptionHandler(org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler)

Aggregations

ResponseEntity (org.springframework.http.ResponseEntity)3 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)3 ResponseEntityExceptionHandler (org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler)3 ErrorResponse (uk.ac.ebi.spot.goci.curation.dto.ErrorResponse)3