package com.lifeix.football.common.application;

import org.apache.http.HttpResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;

import com.lifeix.football.common.exception.AuthorizationException;
import com.lifeix.football.common.exception.BaseException;
import com.lifeix.football.common.exception.BusinessException;
import com.lifeix.football.common.exception.IllegalparamException;
import com.lifeix.football.common.exception.NotFindException;

/**
 * 参见 https://spring.io/blog/2013/11/01/exception-handling-in-spring-mvc 异常处理类
 * 将通用的异常放于此处
 * 
 * add not find exception gcc
 * 
 * @author zengguangwei,gcc
 *
 */
public class ExceptionHandlerAdvice {

    private Logger logger = LoggerFactory.getLogger(ExceptionHandlerAdvice.class);

    /**
     * 授权失败，请求了需要授权的API
     * 
     * @param e
     */
    @ResponseStatus(value = HttpStatus.UNAUTHORIZED, reason = "AuthorizationException")
    @ExceptionHandler(AuthorizationException.class)
    public void AuthorizationException(AuthorizationException e) {
	logger.error("AuthorizationException->" + e.getMessage(), e);
    }

    /**
     * 错误参数异常
     * 
     * @param e
     */
    @ResponseStatus(value = HttpStatus.BAD_REQUEST, reason = "LegalparamException")
    @ExceptionHandler(IllegalparamException.class)
    public void LegalparamException(IllegalparamException e) {
	logger.error("LegalparamException->" + e.getMessage(), e);
    }

    /**
     * 资源未找到异常
     * 
     * @param e
     */
    @ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "NotFindException")
    @ExceptionHandler(NotFindException.class)
    public void NotFindException(NotFindException e) {
	logger.error("NotFindException->" + e.getMessage(), e);
    }

    /**
     * 业务异常，需要客户端知道异常信息
     * 
     * @param e
     */
    @ResponseStatus(value = HttpStatus.BAD_REQUEST, reason = "BaseException")
    @ExceptionHandler(BusinessException.class)
    public void BusinessException(HttpResponse response, BaseException e) {
	logger.error("BaseException->" + e.getMessage(), e);
    }

    /**
     * 基础异常，客户端端请求不能受理
     * 
     * @param e
     */
    @ResponseStatus(value = HttpStatus.BAD_REQUEST, reason = "BaseException")
    @ExceptionHandler(BaseException.class)
    public void BaseException(BaseException e) {
	logger.error("BaseException->" + e.getMessage(), e);
    }

    /**
     * 其他异常不能捕获则进入此方法 ，比如数据库网络失效等非运行时异常
     * 
     * @param e
     */
    @ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR, reason = "Exception")
    @ExceptionHandler(Exception.class)
    public void Exception(Exception e) {
	logger.error("Exception->" + e.getMessage(), e);
    }

}
@@ -46,45 +46,8 @@
 n;%0A%0A
-import org.apache.http.HttpResponse;%0A
 impo
@@ -403,71 +403,8 @@
 on;%0A
-import com.lifeix.football.common.exception.BusinessException;%0A
 impo
@@ -1785,334 +1785,8 @@
  %7D%0A%0A
-    /**%0A     * %E4%B8%9A%E5%8A%A1%E5%BC%82%E5%B8%B8%EF%BC%8C%E9%9C%80%E8%A6%81%E5%AE%A2%E6%88%B7%E7%AB%AF%E7%9F%A5%E9%81%93%E5%BC%82%E5%B8%B8%E4%BF%A1%E6%81%AF%0A     * %0A     * @param e%0A     */%0A    @ResponseStatus(value = HttpStatus.BAD_REQUEST, reason = %22BaseException%22)%0A    @ExceptionHandler(BusinessException.class)%0A    public void BusinessException(HttpResponse response, BaseException e) %7B%0A%09logger.error(%22BaseException-%3E%22 + e.getMessage(), e);%0A    %7D%0A%0A
     

fix bug