异常-Throwable--Error和Exception

引用参考:
--java中的最顶级的异常类Throwable
https://blog.csdn.net/pangqiandou/article/details/53448977
--【系列】重新认识Java语言——异常(Exception)
https://blog.csdn.net/xialei199023/article/details/63251277
--Java 异常Exception e中e的getMessage()和toString()方法的区别
http://blog.csdn.net/qq_34629352/article/details/54018840
--printStackTrace()、toString()、getMessage()的区别
http://blog.csdn.net/qq_34629352/article/details/54018840

示例1:
-->service:
public int doFun(Param p) throws BusinessException{
        int rtnFlag=-1;
        try {
            ......
        }catch (BusinessException e) {
			//业务异常处理
            throw e;
        }catch (Exception e){
        	//其它异常处理
	        logger.error("验证...异常", e);
        	throw new BusinessException("验证...异常", e);
        }
        return rtnFlag;
}

-->controller:
public InterfaceResponse doControllerFum(Map<String, Object> p){
    try{
        InterfaceResponseImpl response = new InterfaceResponseImpl();
	...
	return InterfaceResponse.success("...成功",response);
	...
	return InterfaceResponse.fail("...失败",null); 
    }catch(Exception e){
        logger.error("...service异常:",e);
        return InterfaceResponse.error("...service异常",null);
    }
}

示例2:

猜你喜欢

转载自franciswmf.iteye.com/blog/2359232