package com.cirle.scientific.questionnaire.exception.handle;

import com.cirle.scientific.questionnaire.exception.QuestionnaireNotFoundException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 问卷相关API接口异常处理类
 */
@SuppressWarnings("unused")
@ControllerAdvice
@ResponseBody
public class QuestionnaireExceptionHandler {

    @ExceptionHandler(QuestionnaireNotFoundException.class)
    public Map<String, String> handleQuestionnaireNotFoundException(QuestionnaireNotFoundException e) {
        Map<String, String> map = new LinkedHashMap<>();
        map.put("code", "400");
        map.put("message", e.getMessage());
        return map;
    }

}
