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:io.getlime.push.errorhandling.DefaultExceptionHandler.java

@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) // 500
@ExceptionHandler(Throwable.class)
@ResponseBody/*ww w  .  j ava 2s  . c o  m*/
public ErrorResponse handleConflict(Exception e) {
    ErrorResponse response = new ErrorResponse(new Error(Error.Code.ERROR_GENERIC, e.getMessage()));
    Logger.getLogger(DefaultExceptionHandler.class.getName()).log(Level.SEVERE, null, e);
    return response;
}

From source file:com.redblackit.web.test.RestTemplateTestHelperTest.java

/**
 * Method returning parameters, which also sets up the servlets to use
 *///w  w w  .  j a  va2 s  .c  o m
@Parameters
public static List<Object[]> getParameters() throws Exception {
    final String[] methods = { "GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS" };
    final HttpStatus[][] codes = {
            { HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR,
                    HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR,
                    HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR },
            { HttpStatus.NOT_FOUND, HttpStatus.FORBIDDEN, HttpStatus.CONFLICT, HttpStatus.INTERNAL_SERVER_ERROR,
                    HttpStatus.METHOD_NOT_ALLOWED, HttpStatus.PRECONDITION_FAILED },
            { HttpStatus.NOT_FOUND, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR,
                    HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.NOT_FOUND, HttpStatus.NOT_FOUND } };

    ServletContextHandler jettyContext = new ServletContextHandler(ServletContextHandler.SESSIONS);
    jettyContext.setContextPath("/");
    server.setHandler(jettyContext);

    List<Object[]> parameters = new ArrayList<Object[]>();

    for (int i = 0; i < codes.length; ++i) {
        String url = "/test" + i;
        Map<String, HttpStatus> mcmap = new HashMap<String, HttpStatus>();
        for (int j = 0; j < methods.length; ++j) {
            mcmap.put(methods[j], codes[i][j]);
        }

        jettyContext.addServlet(new ServletHolder(new StatusCodeServlet(mcmap)), url);
        parameters.add(new Object[] { BASE_URL + url, mcmap });
    }

    server.start();
    int i = 0;
    while (!server.isStarted() && i < 20) {
        Thread.sleep(200);
        ++i;
    }

    if (!server.isStarted()) {
        Assert.fail("server not started");
    }
    return parameters;
}

From source file:io.sevenluck.chat.controller.ChatMemberController.java

@ExceptionHandler
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ResponseEntity<?> handleException(MemberAlreadyExistsException e) {
    logger.error("validate:", e.getMessage());
    return new ResponseEntity<>(ExceptionDTO.newConflictInstance(e.getMessage()), new HttpHeaders(),
            HttpStatus.CONFLICT);/*from  w  ww . j  a  va2s .  c o  m*/
}

From source file:org.zalando.riptide.PassThroughResponseErrorHandlerTest.java

@Test
public void isNoErrorForServerError() throws IOException {

    assertThat(unit.hasError(new MockClientHttpResponse(new byte[] {}, HttpStatus.INTERNAL_SERVER_ERROR)),
            is(false));//from ww w  .j a va 2  s. co m
}

From source file:io.sevenluck.chat.controller.LoginController.java

@ExceptionHandler
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ResponseEntity<?> handleException(LoginException e) {
    logger.error("login failed:", e.getMessage());
    return new ResponseEntity<>(ExceptionDTO.newUnauthorizedInstance(e.getMessage()), new HttpHeaders(),
            HttpStatus.UNAUTHORIZED);/*w w  w  .j  a  v a2  s.  c o  m*/
}

From source file:org.osiam.addons.administration.mail.exception.TemplateException.java

public TemplateException(String message, String key) {
    super(message, key, HttpStatus.INTERNAL_SERVER_ERROR.value());
}

From source file:com.github.woki.payments.adyen.simulator.web.controller.PaymentController.java

@RequestMapping(value = { "/pal/servlet/Payment/v30/authorise",
        "/pal/servlet/Payment/v30/authorise3d" }, method = RequestMethod.POST)
public ResponseEntity<PaymentResponse> authorize(@RequestBody PaymentRequest request) {
    PaymentResponse res = new PaymentResponse();
    if ("gimme_500".equals(request.getReference())) {
        res.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
        return new ResponseEntity<>(res, HttpStatus.INTERNAL_SERVER_ERROR);
    }/*  w ww.  j a  v  a  2 s .  c  o m*/
    if ("gimme_400".equals(request.getReference())) {
        res.setStatus(HttpStatus.BAD_REQUEST.value());
        return new ResponseEntity<>(res, HttpStatus.BAD_REQUEST);
    }
    if ("gimme_422".equals(request.getReference())) {
        res.setStatus(HttpStatus.UNPROCESSABLE_ENTITY.value());
        return new ResponseEntity<>(res, HttpStatus.UNPROCESSABLE_ENTITY);
    }
    if ("gimme_401".equals(request.getReference())) {
        res.setStatus(HttpStatus.UNAUTHORIZED.value());
        return new ResponseEntity<>(res, HttpStatus.UNAUTHORIZED);
    }
    if ("gimme_403".equals(request.getReference())) {
        res.setStatus(HttpStatus.FORBIDDEN.value());
        return new ResponseEntity<>(res, HttpStatus.FORBIDDEN);
    }
    if ("gimme_404".equals(request.getReference())) {
        res.setStatus(HttpStatus.NOT_FOUND.value());
        return new ResponseEntity<>(res, HttpStatus.NOT_FOUND);
    }
    if ("gimme_200".equals(request.getReference())) {
        res.setStatus(HttpStatus.OK.value());
        return new ResponseEntity<>(res, HttpStatus.OK);
    }
    res.setStatus(HttpStatus.NON_AUTHORITATIVE_INFORMATION.value());
    return new ResponseEntity<>(res, HttpStatus.NON_AUTHORITATIVE_INFORMATION);
}

From source file:com.mycompany.projetsportmanager.spring.rest.exceptions.SportManagerResponseEntityExceptionHandler.java

@ExceptionHandler(RuntimeException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody// w  ww  .  j  ava  2s  .  c o  m
public ErrorResource processValidationError(RuntimeException ex) {
    return new ErrorResource("uncatched exception", ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}

From source file:uk.gov.hscic.common.config.DefaultControllerExceptionHandler.java

@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(ConfigurationException.class)
public String handleConfigurationException(final ConfigurationException ex) {
    return ex.getMessage();
}

From source file:org.osiam.addons.administration.mail.exception.SendEmailException.java

public SendEmailException(String message, String key, Throwable cause) {
    super(message, key, HttpStatus.INTERNAL_SERVER_ERROR.value(), cause);
}