use of org.springframework.web.bind.annotation.ExceptionHandler in project irida by phac-nml.
the class ExceptionHandlerController method handleAccessDeniedException.
/**
* Handle an {@link AccessDeniedException} and return an Http 403
*
* @param ex
* The caught {@link AccessDeniedException}
* @return name of the access denied view
*/
@ExceptionHandler(AccessDeniedException.class)
@ResponseStatus(HttpStatus.FORBIDDEN)
public ModelAndView handleAccessDeniedException(AccessDeniedException ex) {
logger.error(ex.getMessage(), ex);
ModelAndView modelAndView = new ModelAndView(ACCESS_DENIED_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 handleOAuthProblemException.
/**
* Catch an {@link OAuthProblemException} and return an http 500 error
*
* @param ex
* the caught {@link OAuthProblemException}
* @return A {@link ModelAndView} containing the name of the oauth error
* view
*/
@ExceptionHandler(OAuthProblemException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView handleOAuthProblemException(OAuthProblemException ex) {
logger.error("OAuth exception: " + ex.getMessage(), ex);
ModelAndView modelAndView = new ModelAndView(OAUTH_ERROR_PAGE);
modelAndView.addObject("exception", ex);
modelAndView.addObject("adminEmail", adminEmail);
return modelAndView;
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project irida by phac-nml.
the class ExceptionHandlerController method handleIOException.
/**
* Catch and handle {@link IOException}s. Render an error that's just a
* general storage exception.
*
* @param e
* the exception that was originally thrown.
* @param locale
* the locale of the request.
* @return an error message for general storage exceptions.
*/
@ExceptionHandler(IOException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelMap handleIOException(final IOException e, final Locale locale) {
logger.error("Error writing sequence file", e);
final ModelMap modelMap = new ModelMap();
modelMap.addAttribute("error_message", messageSource.getMessage("project.samples.files.upload.error.storageexception", null, locale));
return modelMap;
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project irida by phac-nml.
the class ControllerExceptionHandler method handleInvalidPropertyException.
/**
* Handle
* {@link ca.corefacility.bioinformatics.irida.exceptions.InvalidPropertyException}
* .
*
* @param e
* the exception as thrown by the service.
* @return an appropriate HTTP response.
*/
@ExceptionHandler(InvalidPropertyException.class)
public ResponseEntity<ErrorResponse> handleInvalidPropertyException(InvalidPropertyException e) {
logger.error("A client attempted to update a resource with an" + " invalid property at " + new Date() + ". The stack trace follows: ", e);
ErrorResponse errorResponse;
Class<? extends Object> affectedClass = e.getAffectedClass();
if (affectedClass != null) {
List<String> properties = getProperties(affectedClass);
String message = "Cannot update resource with supplied properties.";
errorResponse = new ErrorResponse(message);
errorResponse.addProperty("available-properties", properties);
} else {
String message = "Cannot update resource with supplied properties: " + e.getMessage();
errorResponse = new ErrorResponse(message);
}
return new ResponseEntity<>(errorResponse, HttpStatus.BAD_REQUEST);
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project nzbhydra2 by theotherp.
the class NewsWeb method handleNewsException.
@ExceptionHandler(value = { IOException.class })
protected ResponseEntity<ExceptionInfo> handleNewsException(IOException ex, WebRequest request) {
String error = "An error occurred while getting news: " + ex.getMessage();
logger.error(error);
return new ResponseEntity<>(new ExceptionInfo(500, error, ex.getClass().getName(), error, request.getContextPath()), HttpStatus.valueOf(500));
}
Aggregations