Skip to content

Commit

Permalink
add exception handler for the download error
Browse files Browse the repository at this point in the history
  • Loading branch information
alberts-tid committed May 5, 2014
1 parent b24d316 commit 69b52b8
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@

package com.telefonica.euro_iaas.sdc.puppetwrapper.controllers;

import java.io.IOException;
import java.util.NoSuchElementException;

import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

import com.telefonica.euro_iaas.sdc.puppetwrapper.common.Error;
import com.telefonica.euro_iaas.sdc.puppetwrapper.data.ModuleDownloaderException;

public class GenericController {

Expand All @@ -41,6 +40,12 @@ public ModelAndView handleNoSuchElementException(NoSuchElementException ex, Http
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return handleModelAndView(ex.getMessage());
}

@ExceptionHandler(ModuleDownloaderException.class)
public ModelAndView handleModuleDownloaderException(ModuleDownloaderException ex, HttpServletResponse response) {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return handleModelAndView(ex.getMessage());
}

public ModelAndView handleModelAndView(String error) {
ModelAndView model = new ModelAndView();
Expand Down

0 comments on commit 69b52b8

Please sign in to comment.