Example usage for org.springframework.http HttpStatus INTERNAL_SERVER_ERROR

List of usage examples for org.springframework.http HttpStatus INTERNAL_SERVER_ERROR

Introduction

In this page you can find the example usage for org.springframework.http HttpStatus INTERNAL_SERVER_ERROR.

Prototype

HttpStatus INTERNAL_SERVER_ERROR

To view the source code for org.springframework.http HttpStatus INTERNAL_SERVER_ERROR.

Click Source Link

Document

500 Internal Server Error .

Usage

From source file:org.ng200.openolympus.controller.errors.ExceptionHandlingController.java

@ExceptionHandler(Exception.class)
@ResponseBody/* ww w. j  a va 2s  . c o  m*/
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
public String handleException(Exception ex) {
    ExceptionHandlingController.logger.error("Handling error: {}", ex);
    return ex.getMessage();
}

From source file:com.epam.ta.reportportal.commons.exception.rest.ReportPortalExceptionResolver.java

@Override
public RestError resolveError(Exception ex) {

    LOGGER.error("ReportPortalExceptionResolver > " + ex.getMessage(), ex);

    if (ReportPortalException.class.isAssignableFrom(ex.getClass())) {
        ReportPortalException currentException = (ReportPortalException) ex;
        RestError.Builder builder = new RestError.Builder();
        builder.setMessage(currentException.getMessage())
                // .setStackTrace(errors.toString())
                .setStatus(StatusCodeMapping.getHttpStatus(currentException.getErrorType(),
                        HttpStatus.INTERNAL_SERVER_ERROR))
                .setError(currentException.getErrorType());

        return builder.build();
    } else {//from  ww  w  . j av  a 2 s .  com
        return defaultErrorResolver.resolveError(ex);
    }
}

From source file:org.zalando.zmon.actuator.ZmonMetricsFilter.java

@Override
protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response,
        final FilterChain chain) throws ServletException, IOException {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();//from   w ww .  ja  v a  2 s  .c  om

    String path = new UrlPathHelper().getPathWithinApplication(request);
    int status = HttpStatus.INTERNAL_SERVER_ERROR.value();
    try {
        chain.doFilter(request, response);
        status = getStatus(response);
    } finally {
        stopWatch.stop();
        metricsWrapper.recordClientRequestMetrics(request, path, status, stopWatch.getTotalTimeMillis());
    }
}

From source file:com.xyxy.platform.examples.showcase.demos.hystrix.dependency.DependencyResourceController.java

/**
 * ????30?//  w ww  .  j  ava 2s.co  m
 */
@RequestMapping(value = "/hystrix/resource/{id}", method = RequestMethod.GET)
@ResponseBody
public UserDTO getUser(@PathVariable("id") Long id) {
    // .
    if ("normal".equals(status)) {
        return handleRequest(id);
    }

    // 30?.
    if ("timeout".equals(status)) {
        Threads.sleep(TIMEOUT);
        return handleRequest(id);
    }

    // ?.
    if ("server-error".equals(status)) {
        throw new RestException(HttpStatus.INTERNAL_SERVER_ERROR, "Server Exception");
    }

    // 
    if ("bad-request".equals(status)) {
        throw new RestException(HttpStatus.BAD_REQUEST, "Client send a bad request");
    }

    return null;
}

From source file:org.cloudfoundry.identity.uaa.error.ConvertingExceptionViewTests.java

@Test
public void testRender() throws Exception {
    RuntimeException e = new RuntimeException("Unexpected error");
    view = new ConvertingExceptionView(
            new ResponseEntity<ExceptionReport>(new ExceptionReport(e), HttpStatus.INTERNAL_SERVER_ERROR),
            messageConverters);//from   w  ww  . j  av  a2s .c om
    view.render(new HashMap<String, Object>(), request, response);
    assertNotNull(response.getContentAsString());
}

From source file:net.orpiske.tcs.service.rest.controller.ReferencesCommandsController.java

@RequestMapping(method = RequestMethod.POST)
@ResponseBody//from   w  ww  . ja  v a 2  s. c  om
public ResponseEntity<String> updateCloud(@RequestBody ReferenceCreateData data) {
    if (logger.isDebugEnabled()) {
        logger.debug("References command controller handling a create request for " + data);
    }

    ReferenceCreateEvent tagCloudEvent = tagCloudService.createReference(new RequestCreateReference(data));

    if (!tagCloudEvent.isEntityFound()) {
        return new ResponseEntity(HttpStatus.NOT_FOUND);
    }

    if (!tagCloudEvent.isUpdated()) {
        return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
    }

    return new ResponseEntity(HttpStatus.OK);
}

From source file:com.cloudbees.jenkins.plugins.demo.actuator.EndpointsPropertiesSampleActuatorApplicationTests.java

@Test
public void testCustomErrorPath() throws Exception {
    @SuppressWarnings("rawtypes")
    ResponseEntity<Map> entity = new TestRestTemplate("user", "password")
            .getForEntity("http://localhost:" + this.port + "/oops", Map.class);
    assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, entity.getStatusCode());
    @SuppressWarnings("unchecked")
    Map<String, Object> body = entity.getBody();
    assertEquals("None", body.get("error"));
    assertEquals(999, body.get("status"));
}

From source file:jp.classmethod.aws.brian.web.ErrorController.java

@ResponseBody
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@RequestMapping("/500")
public BrianResponse<String> internalServerError(HttpServletRequest req) {
    logger.info("internalServerError invoked {}", req);
    return new BrianResponse<>(false, "500 - Internal Server Error", null);
}

From source file:com.intel.databackend.handlers.ErrorHandler.java

@ExceptionHandler(ServiceException.class)
public ResponseEntity handleError(ServiceException ex) {
    logger.error("Unable to read dashboard api url", ex);
    return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
}

From source file:com.lixiaocong.exception.ExceptionControllerAdvice.java

@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(ControllerParamException.class)
public ModelAndView handleIOException() {
    return new ModelAndView("/error/500");
}