package com.dcit.authority.handler;

import org.apache.shiro.authc.AuthenticationException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dcit.authority.exception.AuthException;
import com.dcit.common.enums.ResultEnum;
import com.dcit.common.utils.ResultVOUtil;
import com.dcit.common.vo.ResultVO;


/**
* <p>Title: CustomizedExceptionHandler</p>
* <p>Description: 统一异常处理</p>
* <p>Company: SJZ DC-IT co. LTD</p> 
* @author ZZZ
* @date 2018年9月9日 上午10:47:57
*/

@ControllerAdvice
public class CustomizedExceptionHandler {

	@ExceptionHandler(value=AuthenticationException.class)
	@ResponseBody
	public ResultVO<Object> handlerAuthenticationException(){
		return ResultVOUtil.error(ResultEnum.ERROR_JWT);
	}
	
	@ExceptionHandler(value=AuthException.class)
	@ResponseBody
	public ResultVO<Object> handlerAuthException(AuthException e){
		return ResultVOUtil.error(e.getCode(),e.getMessage());
	}
}
