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:com.mycompany.bootcamelrestdsl.Application.java
@Bean public EmbeddedServletContainerCustomizer containerCustomizer() { return new EmbeddedServletContainerCustomizer() { @Override/*ww w . j av a 2 s .c om*/ 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); } }; }
From source file:org.osiam.addons.self_administration.exception.OsiamExceptionHandler.java
@ExceptionHandler(OsiamClientException.class) protected ModelAndView handleConflict(OsiamClientException ex, HttpServletResponse response) { LOGGER.error(AN_EXCEPTION_OCCURED, ex); return createResponse(response, HttpStatus.INTERNAL_SERVER_ERROR.value(), "registration.form.error"); }
From source file:eu.cloudwave.wp5.feedbackhandler.controller.AbstractBaseRestController.java
/** * Is called whenever an {@link Exception} in a controller method is thrown. * /*from w ww . j a v a 2 s . c o m*/ * @param exception * the exception that arose * @param request * the request that caused the exception * @return an error message */ @ExceptionHandler(Exception.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseBody public final RestRequestErrorDto handleException(final Exception exception, final HttpServletRequest request) { LogManager.getLogger(getClass()).error(String.format(EXCEPTION_MESSAGE, request.getRequestURI()), exception); return new RestRequestErrorDto(ErrorType.GENERAL, exception.getMessage()); }
From source file:de.steilerdev.myVerein.server.controller.user.DivisionController.java
@RequestMapping(method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Division> getDivision(@RequestParam(value = "id") String divisionID, @CurrentUser User currentUser) { logger.trace("[" + currentUser + "] Loading division with ID " + divisionID); Division searchedDivision;//w w w .jav a 2s . com if (divisionID.isEmpty()) { logger.warn("[" + currentUser + "] The division ID is empty"); return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } else if ((searchedDivision = divisionRepository.findById(divisionID)) == null) { logger.warn("[" + currentUser + "] Unable to find division with the stated ID " + divisionID); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } else { logger.info("[" + currentUser + "] Returning division with ID " + divisionID); return new ResponseEntity<>(searchedDivision.getSendingObjectInternalSync(), HttpStatus.OK); } }
From source file:org.appverse.web.framework.backend.frontfacade.rest.handler.MvcExceptionHandler.java
@ExceptionHandler(Exception.class) public ResponseEntity<ResponseDataVO> handleError(HttpServletRequest req, Exception exception) { ResponseDataVO data = new ResponseDataVO(); ErrorVO error = new ErrorVO(); Long code = 500L;/*from www .j av a2 s.c o m*/ HttpStatus httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; if (exception instanceof AbstractException) { if (((AbstractException) exception).getCode() != null) { code = ((AbstractException) exception).getCode(); } } error.setCode(code); error.setMessage(exception.getMessage()); data.setErrorVO(error); return new ResponseEntity<ResponseDataVO>(data, httpStatus); }
From source file:alfio.controller.api.AttendeeApiController.java
@ExceptionHandler(RuntimeException.class) public ResponseEntity<String> handleGenericException(RuntimeException e) { log.error("unexpected exception", e); return new ResponseEntity<>("unexpected error", HttpStatus.INTERNAL_SERVER_ERROR); }
From source file:org.openlmis.notification.web.NotificationController.java
/** * Logs any exceptions that occur while sending notifications and returns proper response. * * @param ex An instance of Exception/*from www .ja v a 2s. c om*/ * @return ErrorResponse */ @ExceptionHandler(Exception.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseBody public ErrorResponse handleException(Exception ex) { final String msg = "Unable to send notification"; LOGGER.error(msg, ex); return new ErrorResponse(msg, ex.getMessage()); }
From source file:org.smigo.config.RestExceptionResolver.java
@Override public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {/*from ww w . ja v a 2 s. c o m*/ if (ex instanceof AccessDeniedException) { return getModelAndView(response, HttpStatus.FORBIDDEN, new Object[] { new ObjectError("AccessDenied", "msg.needtobeloggedin") }); } final String uri = (String) request.getAttribute("javax.servlet.error.request_uri"); if (request.getRequestURI().startsWith("/rest/") || uri != null && uri.startsWith("/rest/")) { return getModelAndView(response, HttpStatus.INTERNAL_SERVER_ERROR, new Object[] { new ObjectError("unknown-error", "msg.unknownerror") }); } if (handler == null) { return null; } try { final HandlerMethod handlerMethod = (HandlerMethod) handler; final boolean annotatedWithRestController = handlerMethod.getBeanType() .isAnnotationPresent(RestController.class); final boolean annotatedWithResponseBody = handlerMethod.getMethodAnnotation(ResponseBody.class) != null; if (annotatedWithResponseBody || annotatedWithRestController) { return getModelAndView(response, HttpStatus.INTERNAL_SERVER_ERROR, new Object[] { new ObjectError("unknown-error", "msg.unknownerror") }); } } catch (Exception e) { log.error("Failed to return object error. Handler:" + handler, ex); } return null; }
From source file:fr.gmjgav.controller.BarController.java
@RequestMapping(value = "/beerName/{location:.+}/{name}", method = GET) public ResponseEntity<?> getByBeerName(@PathVariable String location, @PathVariable String name) { Beer beer;//from ww w . ja v a2 s . c om try { beer = beerRepository.findByName(name).get(0); List<Bar> barsForBeer = beer.getBars(); ListAndStatus returnedBars = GooglePlacesManager.intersectBarsAndPlaces(barsForBeer, barRepository, new Coordinates(location)); return new ResponseEntity<>(returnedBars.getList(), returnedBars.getResponseCode()); } catch (IndexOutOfBoundsException e) { return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } }
From source file:de.steilerdev.myVerein.server.controller.user.UserController.java
@RequestMapping(method = RequestMethod.GET, produces = "application/json") public ResponseEntity<User> getUser(@RequestParam(value = "id") String userID, @CurrentUser User currentUser) { logger.trace("[{}] Loading user with ID {}", currentUser, userID); User searchedUser;/*from w w w . j a va 2 s . c om*/ if (userID.isEmpty()) { logger.warn("[" + currentUser + "] The user ID is empty"); return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } else if ((searchedUser = userRepository.findById(userID)) == null) { logger.warn("[" + currentUser + "] Unable to find user with the stated ID " + userID); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } else { logger.info("[" + currentUser + "] Returning user with ID " + userID); return new ResponseEntity<>(searchedUser.getSendingObjectInternalSync(), HttpStatus.OK); } }