Search in sources :

Example 1 with ErrorHandler

use of com.thoughtworks.go.server.util.ErrorHandler in project gocd by gocd.

the class ArtifactsController method handleError.

@ErrorHandler
public ModelAndView handleError(HttpServletRequest request, HttpServletResponse response, Exception e) {
    LOGGER.error("Error loading artifacts: ", e);
    Map model = new HashMap();
    model.put(ERROR_FOR_PAGE, "Artifact does not exist.");
    return new ModelAndView("exceptions_page", model);
}
Also used : HashMap(java.util.HashMap) FileModelAndView(com.thoughtworks.go.server.web.FileModelAndView) ModelAndView(org.springframework.web.servlet.ModelAndView) HashMap(java.util.HashMap) Map(java.util.Map) ErrorHandler(com.thoughtworks.go.server.util.ErrorHandler)

Example 2 with ErrorHandler

use of com.thoughtworks.go.server.util.ErrorHandler in project gocd by gocd.

the class StageController method handleError.

@ErrorHandler
public ModelAndView handleError(HttpServletRequest request, HttpServletResponse response, Exception e) {
    Map<String, Object> json = new LinkedHashMap<>();
    String message = e.getMessage();
    if (e instanceof StageNotFoundException) {
        StageNotFoundException stageNotFoundException = (StageNotFoundException) e;
        message = format("Stage '%s' of pipeline '%s' does not exist in current configuration. You can not rerun it.", stageNotFoundException.getStageName(), stageNotFoundException.getPipelineName());
    }
    addFriendlyErrorMessage(json, message);
    return jsonNotAcceptable(json).respond(response);
}
Also used : StageNotFoundException(com.thoughtworks.go.config.StageNotFoundException) LinkedHashMap(java.util.LinkedHashMap) ErrorHandler(com.thoughtworks.go.server.util.ErrorHandler)

Aggregations

ErrorHandler (com.thoughtworks.go.server.util.ErrorHandler)2 StageNotFoundException (com.thoughtworks.go.config.StageNotFoundException)1 FileModelAndView (com.thoughtworks.go.server.web.FileModelAndView)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1