List of usage examples for org.springframework.http HttpStatus INTERNAL_SERVER_ERROR
HttpStatus INTERNAL_SERVER_ERROR
To view the source code for org.springframework.http HttpStatus INTERNAL_SERVER_ERROR.
Click Source Link
From source file:io.sevenluck.chat.controller.ChatChannelController.java
@ExceptionHandler @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) public ResponseEntity<?> handleException(EntityNotFoundException e) { logger.error("validate:", e.getMessage()); return new ResponseEntity<>(ExceptionDTO.newNotFoundInstance(e.getMessage()), new HttpHeaders(), HttpStatus.NOT_FOUND);/*from w ww . ja v a 2 s . c om*/ }
From source file:alfio.controller.api.admin.SpecialPriceApiController.java
@ExceptionHandler @ResponseBody//from w w w. j a va 2 s . co m @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) public String handleExceptions(Exception e) { if (!IllegalArgumentException.class.isInstance(e)) { log.error("Unexpected exception in SpecialPriceApiController", e); return e.toString(); } return e.getMessage(); }
From source file:com.crazyacking.learn.spring.actuator.ServletPathSampleActuatorApplicationTests.java
@Test public void testErrorPath() { @SuppressWarnings("rawtypes") ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword()) .getForEntity("/spring/error", Map.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); @SuppressWarnings("unchecked") Map<String, Object> body = entity.getBody(); assertThat(body.get("error")).isEqualTo("None"); assertThat(body.get("status")).isEqualTo(999); }
From source file:alfio.controller.api.admin.LocationApiController.java
@ExceptionHandler(Exception.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) public String unhandledException(Exception e) { return e.getMessage(); }
From source file:org.fede.calculator.web.controller.LaPlataAddressCalculator.java
@ExceptionHandler(Exception.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) public LaPlataAddressDTO errorHandler(Exception ex) { LOG.log(Level.SEVERE, "errorHandler", ex); return new LaPlataAddressDTO("La direccin ingresada no es vlida.", ""); }
From source file:com.ge.predix.acs.commons.web.RestApiExceptionTest.java
@Test public void testRestApiExceptionWithMessage() { RestApiException apiException = new RestApiException("message"); Assert.assertEquals(apiException.getMessage(), "message"); Assert.assertEquals(apiException.getAppErrorCode(), "FAILURE"); Assert.assertEquals(apiException.getHttpStatusCode(), HttpStatus.INTERNAL_SERVER_ERROR); }
From source file:org.zalando.riptide.OAuth2CompatibilityResponseErrorHandlerTest.java
@Test public void isNoErrorForServerError() throws IOException { final ClientHttpResponse response = new MockClientHttpResponse(new byte[] {}, HttpStatus.INTERNAL_SERVER_ERROR); assertThat(unit.hasError(response), is(false)); }
From source file:fi.helsinki.opintoni.web.rest.privateapi.TestResource.java
@RequestMapping(value = "/internalservererror", method = RequestMethod.GET) @Timed//from ww w. j a v a 2 s. com public ResponseEntity<Map<String, String>> return500Error() { return new ResponseEntity<>(ImmutableMap.of("message", "error"), HttpStatus.INTERNAL_SERVER_ERROR); }
From source file:com.crazyacking.learn.spring.actuator.EndpointsPropertiesSampleActuatorApplicationTests.java
@Test public void testCustomErrorPath() { @SuppressWarnings("rawtypes") ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword()).getForEntity("/oops", Map.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); @SuppressWarnings("unchecked") Map<String, Object> body = entity.getBody(); assertThat(body.get("error")).isEqualTo("None"); assertThat(body.get("status")).isEqualTo(999); }
From source file:com.xyxy.platform.examples.showcase.demos.hystrix.web.HystrixExceptionHandler.java
/** * ?Hystrix Runtime, :/*from w w w .j a v a 2 s .com*/ * Command(500). * Hystrix??(503). */ @ExceptionHandler(value = { HystrixRuntimeException.class }) public final ResponseEntity<?> handleException(HystrixRuntimeException e, WebRequest request) { HttpStatus status = HttpStatus.SERVICE_UNAVAILABLE; String message = e.getMessage(); FailureType type = e.getFailureType(); // ? if (type.equals(FailureType.COMMAND_EXCEPTION)) { status = HttpStatus.INTERNAL_SERVER_ERROR; message = Exceptions.getErrorMessageWithNestedException(e); } logger.error(message, e); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.parseMediaType(MediaTypes.TEXT_PLAIN_UTF_8)); return handleExceptionInternal(e, message, headers, status, request); }