Search in sources :

Example 1 with ErrorInfo

use of com.haulmont.restapi.exception.ErrorInfo in project cuba by cuba-platform.

the class RestControllerExceptionHandler method handleMethodResultValidationException.

@ExceptionHandler(MethodResultValidationException.class)
@ResponseBody
public ResponseEntity<ErrorInfo> handleMethodResultValidationException(MethodResultValidationException e) {
    log.error("MethodResultValidationException in service", e);
    ErrorInfo errorInfo = new ErrorInfo("Server error", "");
    return new ResponseEntity<>(errorInfo, HttpStatus.INTERNAL_SERVER_ERROR);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ErrorInfo(com.haulmont.restapi.exception.ErrorInfo) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with ErrorInfo

use of com.haulmont.restapi.exception.ErrorInfo in project cuba by cuba-platform.

the class RestControllerExceptionHandler method handleValidationException.

@ExceptionHandler(ValidationException.class)
@ResponseBody
public ResponseEntity<ErrorInfo> handleValidationException(ValidationException e) {
    log.error("ValidationException in service", e);
    ErrorInfo errorInfo = new ErrorInfo("Server error", "");
    return new ResponseEntity<>(errorInfo, HttpStatus.INTERNAL_SERVER_ERROR);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ErrorInfo(com.haulmont.restapi.exception.ErrorInfo) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with ErrorInfo

use of com.haulmont.restapi.exception.ErrorInfo in project cuba by cuba-platform.

the class RestControllerExceptionHandler method handleException.

@ExceptionHandler(Exception.class)
@ResponseBody
public ResponseEntity<ErrorInfo> handleException(Exception e) {
    log.error("Exception in REST controller", e);
    ErrorInfo errorInfo = new ErrorInfo("Server error", "");
    return new ResponseEntity<>(errorInfo, HttpStatus.INTERNAL_SERVER_ERROR);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ErrorInfo(com.haulmont.restapi.exception.ErrorInfo) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with ErrorInfo

use of com.haulmont.restapi.exception.ErrorInfo in project cuba by cuba-platform.

the class RestControllerExceptionHandler method handleRowLevelSecurityException.

@ExceptionHandler(RowLevelSecurityException.class)
@ResponseBody
public ResponseEntity<ErrorInfo> handleRowLevelSecurityException(RowLevelSecurityException e) {
    log.error("RowLevelSecurityException in service", e);
    ErrorInfo errorInfo = new ErrorInfo("Forbidden", e.getMessage());
    return new ResponseEntity<>(errorInfo, HttpStatus.FORBIDDEN);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ErrorInfo(com.haulmont.restapi.exception.ErrorInfo) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ErrorInfo (com.haulmont.restapi.exception.ErrorInfo)4 ResponseEntity (org.springframework.http.ResponseEntity)4 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4