Java Code Examples for org.springframework.http.ResponseEntity.BodyBuilder#body()
The following examples show how to use
org.springframework.http.ResponseEntity.BodyBuilder#body() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExceptionTranslator.java From jhipster-microservices-example with Apache License 2.0 | 6 votes |
@ExceptionHandler(Exception.class) public ResponseEntity<ErrorVM> processException(Exception ex) { if (log.isDebugEnabled()) { log.debug("An unexpected error occured: {}", ex.getMessage(), ex); } else { log.error("An unexpected error occured: {}", ex.getMessage()); } BodyBuilder builder; ErrorVM errorVM; ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class); if (responseStatus != null) { builder = ResponseEntity.status(responseStatus.value()); errorVM = new ErrorVM("error." + responseStatus.value().value(), responseStatus.reason()); } else { builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR); errorVM = new ErrorVM(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error"); } return builder.body(errorVM); }
Example 2
Source File: ExceptionTranslator.java From jhipster-microservices-example with Apache License 2.0 | 6 votes |
@ExceptionHandler(Exception.class) public ResponseEntity<ErrorVM> processException(Exception ex) { if (log.isDebugEnabled()) { log.debug("An unexpected error occured: {}", ex.getMessage(), ex); } else { log.error("An unexpected error occured: {}", ex.getMessage()); } BodyBuilder builder; ErrorVM errorVM; ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class); if (responseStatus != null) { builder = ResponseEntity.status(responseStatus.value()); errorVM = new ErrorVM("error." + responseStatus.value().value(), responseStatus.reason()); } else { builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR); errorVM = new ErrorVM(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error"); } return builder.body(errorVM); }
Example 3
Source File: ExceptionTranslator.java From klask-io with GNU General Public License v3.0 | 6 votes |
@ExceptionHandler(Exception.class) public ResponseEntity<ErrorDTO> processRuntimeException(Exception ex) throws Exception { BodyBuilder builder; ErrorDTO errorDTO; ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class); if (responseStatus != null) { builder = ResponseEntity.status(responseStatus.value()); errorDTO = new ErrorDTO("error." + responseStatus.value().value(), responseStatus.reason()); } else { builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR); errorDTO = new ErrorDTO(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error"); } log.error("Exception in rest call", ex); errorDTO.add("error", "error", ex.getMessage()); return builder.body(errorDTO); }
Example 4
Source File: ExceptionTranslator.java From flair-registry with Apache License 2.0 | 5 votes |
@ExceptionHandler(Exception.class) public ResponseEntity<ErrorVM> processRuntimeException(Exception ex) { BodyBuilder builder; ErrorVM errorVM; ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class); if (responseStatus != null) { builder = ResponseEntity.status(responseStatus.value()); errorVM = new ErrorVM("error." + responseStatus.value().value(), responseStatus.reason()); } else { builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR); errorVM = new ErrorVM(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error"); } return builder.body(errorVM); }
Example 5
Source File: ExceptionTranslator.java From flair-engine with Apache License 2.0 | 5 votes |
@ExceptionHandler(Exception.class) public ResponseEntity<ErrorVM> processException(Exception ex) { if (log.isDebugEnabled()) { log.debug("An unexpected error occurred: {}", ex.getMessage(), ex); } else { log.error("An unexpected error occurred: {}", ex.getMessage()); } BodyBuilder builder; ErrorVM errorVM; ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class); if (responseStatus != null) { builder = ResponseEntity.status(responseStatus.value()); errorVM = new ErrorVM("error." + responseStatus.value().value(), responseStatus.reason()); } else { builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR); errorVM = new ErrorVM(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error"); } return builder.body(errorVM); }
Example 6
Source File: ExceptionTranslator.java From jhipster-microservices-example with Apache License 2.0 | 5 votes |
@ExceptionHandler(Exception.class) public ResponseEntity<ErrorVM> processRuntimeException(Exception ex) { BodyBuilder builder; ErrorVM errorVM; ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class); if (responseStatus != null) { builder = ResponseEntity.status(responseStatus.value()); errorVM = new ErrorVM("error." + responseStatus.value().value(), responseStatus.reason()); } else { builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR); errorVM = new ErrorVM(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error"); } return builder.body(errorVM); }
Example 7
Source File: ExceptionTranslator.java From jhipster-ribbon-hystrix with GNU General Public License v3.0 | 5 votes |
@ExceptionHandler(Exception.class) public ResponseEntity<ErrorDTO> processRuntimeException(Exception ex) throws Exception { BodyBuilder builder; ErrorDTO errorDTO; ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class); if (responseStatus != null) { builder = ResponseEntity.status(responseStatus.value()); errorDTO = new ErrorDTO("error." + responseStatus.value().value(), responseStatus.reason()); } else { builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR); errorDTO = new ErrorDTO(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error"); } return builder.body(errorDTO); }
Example 8
Source File: ExceptionTranslator.java From jhipster-ribbon-hystrix with GNU General Public License v3.0 | 5 votes |
@ExceptionHandler(Exception.class) public ResponseEntity<ErrorDTO> processRuntimeException(Exception ex) throws Exception { BodyBuilder builder; ErrorDTO errorDTO; ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class); if (responseStatus != null) { builder = ResponseEntity.status(responseStatus.value()); errorDTO = new ErrorDTO("error." + responseStatus.value().value(), responseStatus.reason()); } else { builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR); errorDTO = new ErrorDTO(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error"); } return builder.body(errorDTO); }
Example 9
Source File: _ExceptionTranslator.java From jhipster-ribbon-hystrix with GNU General Public License v3.0 | 5 votes |
@ExceptionHandler(Exception.class) public ResponseEntity<ErrorDTO> processRuntimeException(Exception ex) throws Exception { BodyBuilder builder; ErrorDTO errorDTO; ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class); if (responseStatus != null) { builder = ResponseEntity.status(responseStatus.value()); errorDTO = new ErrorDTO("error." + responseStatus.value().value(), responseStatus.reason()); } else { builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR); errorDTO = new ErrorDTO(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error"); } return builder.body(errorDTO); }
Example 10
Source File: ExceptionTranslator.java From jhipster-ribbon-hystrix with GNU General Public License v3.0 | 5 votes |
@ExceptionHandler(Exception.class) public ResponseEntity<ErrorDTO> processRuntimeException(Exception ex) throws Exception { BodyBuilder builder; ErrorDTO errorDTO; ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class); if (responseStatus != null) { builder = ResponseEntity.status(responseStatus.value()); errorDTO = new ErrorDTO("error." + responseStatus.value().value(), responseStatus.reason()); } else { builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR); errorDTO = new ErrorDTO(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error"); } return builder.body(errorDTO); }
Example 11
Source File: ExceptionTranslator.java From gpmr with Apache License 2.0 | 5 votes |
@ExceptionHandler(Exception.class) public ResponseEntity<ErrorDTO> processRuntimeException(Exception ex) throws Exception { BodyBuilder builder; ErrorDTO errorDTO; ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class); if (responseStatus != null) { builder = ResponseEntity.status(responseStatus.value()); errorDTO = new ErrorDTO("error." + responseStatus.value().value(), responseStatus.reason()); } else { builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR); errorDTO = new ErrorDTO(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error"); } return builder.body(errorDTO); }
Example 12
Source File: ExceptionTranslator.java From OpenIoE with Apache License 2.0 | 5 votes |
@ExceptionHandler(Exception.class) public ResponseEntity<ErrorDTO> processRuntimeException(Exception ex) throws Exception { BodyBuilder builder; ErrorDTO errorDTO; ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class); if (responseStatus != null) { builder = ResponseEntity.status(responseStatus.value()); errorDTO = new ErrorDTO("error." + responseStatus.value().value(), responseStatus.reason()); } else { builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR); errorDTO = new ErrorDTO(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error"); } return builder.body(errorDTO); }
Example 13
Source File: ExceptionTranslator.java From tutorials with MIT License | 5 votes |
@ExceptionHandler(Exception.class) public ResponseEntity<ErrorVM> processRuntimeException(Exception ex) { BodyBuilder builder; ErrorVM errorVM; ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class); if (responseStatus != null) { builder = ResponseEntity.status(responseStatus.value()); errorVM = new ErrorVM("error." + responseStatus.value().value(), responseStatus.reason()); } else { builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR); errorVM = new ErrorVM(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error"); } return builder.body(errorVM); }
Example 14
Source File: ExceptionTranslator.java From tutorials with MIT License | 5 votes |
@ExceptionHandler(Exception.class) public ResponseEntity<ErrorVM> processRuntimeException(Exception ex) { BodyBuilder builder; ErrorVM errorVM; ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class); if (responseStatus != null) { builder = ResponseEntity.status(responseStatus.value()); errorVM = new ErrorVM("error." + responseStatus.value().value(), responseStatus.reason()); } else { builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR); errorVM = new ErrorVM(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error"); } return builder.body(errorVM); }
Example 15
Source File: ExceptionTranslator.java From tutorials with MIT License | 5 votes |
@ExceptionHandler(Exception.class) public ResponseEntity<ErrorVM> processRuntimeException(Exception ex) { BodyBuilder builder; ErrorVM errorVM; ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class); if (responseStatus != null) { builder = ResponseEntity.status(responseStatus.value()); errorVM = new ErrorVM("error." + responseStatus.value().value(), responseStatus.reason()); } else { builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR); errorVM = new ErrorVM(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error"); } return builder.body(errorVM); }
Example 16
Source File: ExceptionTranslator.java From tutorials with MIT License | 5 votes |
@ExceptionHandler(Exception.class) public ResponseEntity<ErrorVM> processRuntimeException(Exception ex) { BodyBuilder builder; ErrorVM errorVM; ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class); if (responseStatus != null) { builder = ResponseEntity.status(responseStatus.value()); errorVM = new ErrorVM("error." + responseStatus.value().value(), responseStatus.reason()); } else { builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR); errorVM = new ErrorVM(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error"); } return builder.body(errorVM); }