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:com.nazara.proxy.api.Endpoint.java

@RequestMapping(path = "/status", method = RequestMethod.GET)
@ResponseBody/*ww w  .  jav  a2 s  . c  o  m*/
public ResponseEntity<Object> proxyRequest(@RequestParam(value = "msisdn", required = false) String msisdn) {
    logger.info("status request arrived");
    try {
        HttpResponse<IPInfo> ipInfoResponse = Unirest.get("http://ipinfo.io/")
                .header("accept", "application/json").asObject(IPInfo.class);
        if (ipInfoResponse.getStatus() == 200) {
            return new ResponseEntity<Object>(ipInfoResponse.getBody(), HttpStatus.OK);
        }
    } catch (Exception exception) {
        logger.error("Error while processing proxy request {}", exception);
        return new ResponseEntity<Object>("NOK|ERR_CODE", HttpStatus.INTERNAL_SERVER_ERROR);
    }
    return new ResponseEntity<Object>("NOK|ERR_CODE", HttpStatus.NO_CONTENT);
}

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

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

From source file:org.jug.bg.rest.hateoas.spring.common.resource.AbstractResource.java

/**
 * Handles internal server error./*w w w  .j a  va  2s. c  o m*/
 *
 * @param runtimeException Unspecified exception.
 */
@ExceptionHandler(RuntimeException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public void handle(RuntimeException runtimeException) {
    handleError(runtimeException, "Handling unspecified exception.");
}

From source file:org.craftercms.deployer.impl.rest.ExceptionHandlers.java

@ExceptionHandler(Exception.class)
public ResponseEntity<Object> handleGeneralException(Exception exception, WebRequest webRequest) {
    return handleExceptionInternal(exception, null, new HttpHeaders(), HttpStatus.INTERNAL_SERVER_ERROR,
            webRequest);/*from w  w  w  .  ja v  a  2  s.co m*/
}

From source file:fr.treeptik.cloudunit.config.CustomResponseHandler.java

@ExceptionHandler({ CheckException.class, ServiceException.class, NoSuchMessageException.class,
        NumberFormatException.class, ClassCastException.class })
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
public @ResponseBody HttpErrorServer handleException(CheckException e) {
    return new HttpErrorServer(e.getMessage());
}

From source file:fr.olympicinsa.riocognized.exception.MyExceptionHandler.java

@ExceptionHandler(NoSuchRequestHandlingMethodException.class)
@ResponseBody//ww  w.  j  a v a2s.c om
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ErrorMessage handleNotFoundErrorException(NoSuchRequestHandlingMethodException e,
        HttpServletRequest req) {
    return new ErrorMessage("INTERNAL_SERVER_ERROR");
}

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

@Test
public void testGetContentType() throws Exception {
    RuntimeException e = new RuntimeException("Unexpected error");
    view = new ConvertingExceptionView(
            new ResponseEntity<ExceptionReport>(new ExceptionReport(e), HttpStatus.INTERNAL_SERVER_ERROR),
            messageConverters);/*ww  w  .  ja v  a2 s.  c  o  m*/
    assertEquals("*/*", view.getContentType());
}

From source file:things.view.rest.ThingRestExceptionHandler.java

@ExceptionHandler(Error.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody/*  ww  w  . ja v a2  s . com*/
public ErrorInfo error(final HttpServletRequest req, final Error ex) {

    myLogger.debug("Exception: " + ex.getLocalizedMessage(), ex);

    return new ErrorInfo(req.getRequestURL().toString(), ex);
}

From source file:com.opensearchserver.hadse.index.IndexCatalog.java

public final static ResponseEntity<?> create(String indexName, int shards, int replicas)
        throws HadseIndexException, JsonGenerationException, JsonMappingException, IOException {
    File indexDirectory = new File(Hadse.data_dir, indexName);
    if (indexDirectory.exists())
        return new ResponseEntity<Object>(HttpStatus.CONFLICT);
    if (!indexDirectory.mkdir())
        return new ResponseEntity<String>("Unable to create the index directory",
                HttpStatus.INTERNAL_SERVER_ERROR);
    IndexItem indexItem = IndexItem.get(indexName);
    for (int shard = 1; shard <= shards; shard++) {
        String shardName = Integer.toString(shard);
        ShardDef shardDef = ShardDef.write(indexDirectory, shardName, ClusterCatalog.nextShardCandidate());
        indexItem.add(ShardItem.load(shardDef, indexDirectory));
    }/*from  w  w  w.  j av a2s  .c o  m*/
    return new ResponseEntity<String>("Index created: " + indexName, HttpStatus.CREATED);
}

From source file:org.systemexception.springmongorest.Application.java

@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() {

    return new EmbeddedServletContainerCustomizer() {
        @Override/*  www.j  ava  2  s  .c  o  m*/
        public void customize(ConfigurableEmbeddedServletContainer container) {

            ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/401.html");
            ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
            ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.html");

            container.addErrorPages(error401Page, error404Page, error500Page);
        }
    };
}