use of org.springframework.web.bind.annotation.ExceptionHandler in project tutorials by eugenp.
the class RestResponseEntityExceptionHandler method handleInternal.
// 412
// 500
@ExceptionHandler({ NullPointerException.class, IllegalArgumentException.class, IllegalStateException.class })
public /*500*/
ResponseEntity<Object> handleInternal(final RuntimeException ex, final WebRequest request) {
logger.error("500 Status Code", ex);
final String bodyOfResponse = "This should be application specific";
return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.INTERNAL_SERVER_ERROR, request);
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project dubidubi by lzzzz4.
the class BaseExceptionController method ajaxUnAuthorHandle.
@ExceptionHandler(UnauthorizedException.class)
@ResponseBody
public /**
* @Description:当ajax请求页面时,未授权用户抛出的异常处理
* @param response
* @return
*/
AjaxResultDTO ajaxUnAuthorHandle(HttpServletResponse response) {
AjaxResultDTO ajaxResultDTO = new AjaxResultDTO();
// 设置错误码为1000,授权失败
ajaxResultDTO.setCode(1000);
return ajaxResultDTO;
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project motech by motech.
the class UserController method handlePasswordValidatorException.
@ExceptionHandler(PasswordValidatorException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public String handlePasswordValidatorException(HttpServletRequest request, PasswordValidatorException ex) {
LOGGER.debug("Password did not pass validation: {}", ex.getMessage());
Locale locale = localeService.getUserLocale(request);
String errorMsg = settingService.getPasswordValidator().getValidationError(locale);
return "literal:" + errorMsg;
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project irida by phac-nml.
the class ExceptionHandlerController method handleResourceNotFoundException.
/**
* Handle an {@link EntityNotFoundException} and return an http 404
*
* @param ex
* The EntityNotFoundException caught
* @return the name of the not_found view
*/
@ExceptionHandler(EntityNotFoundException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
public ModelAndView handleResourceNotFoundException(EntityNotFoundException ex) {
logger.error(ex.getMessage(), ex);
ModelAndView modelAndView = new ModelAndView(NOT_FOUND_PAGE);
modelAndView.addObject("adminEmail", adminEmail);
return modelAndView;
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project irida by phac-nml.
the class ExceptionHandlerController method handleOtherExceptions.
/**
* Catch all other exception types and display a generic error page and 500
* error
*
* @param ex
* The caught exception
* @return Name of the generic error page
*/
@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView handleOtherExceptions(Exception ex) {
logger.error(ex.getMessage(), ex);
ModelAndView modelAndView = new ModelAndView(OTHER_ERROR_PAGE);
modelAndView.addObject("adminEmail", adminEmail);
return modelAndView;
}
Aggregations