Project

General

Profile

1
package eu.dnetlib.vocabularies.publisher.controller;
2

    
3
import eu.dnetlib.vocabularies.publisher.VocabularyNotFoundException;
4
import org.springframework.http.HttpStatus;
5
import org.springframework.web.bind.annotation.ControllerAdvice;
6
import org.springframework.web.bind.annotation.ExceptionHandler;
7
import org.springframework.web.bind.annotation.ResponseStatus;
8
import org.springframework.web.servlet.ModelAndView;
9

    
10
@ControllerAdvice
11
public class VocabularyExceptionController {
12

    
13
    @ResponseStatus(HttpStatus.NOT_FOUND)
14
    @ExceptionHandler(VocabularyNotFoundException.class)
15
    public ModelAndView exception(final VocabularyNotFoundException e) {
16

    
17
        ModelAndView mav = new ModelAndView("error");
18
        mav.addObject("message", e.getMessage());
19
        return mav;
20
    }
21
}
(1-1/2)