Commit eccb2f96 by qiuweili123

异常策略优化

parent a72efeb8
......@@ -36,10 +36,10 @@ public class ProtocolExceptionHandler {
LoggerUtil.info(msg);
return ResponseUtil.getFailResponse(ex.getCode(), msg);
} catch (SystemInternalException ex) {
LoggerUtil.error(e);
LoggerUtil.warn("WarnError",ex);
return ResponseUtil.getFailResponse(CommonErrorCode.SYSTEM_INTERNAL_EXCEPTION.getCode(), CommonErrorCode.SYSTEM_INTERNAL_EXCEPTION.getMsg());
} catch (BusinessException ex) {
LoggerUtil.warn("businessException info:", ex);
LoggerUtil.warn("BizError:", ex);
return ResponseUtil.getFailResponse(ex.getCode(), getMsg(ex));
} catch (Exception ex) {
LoggerUtil.error(ex);
......
package com.secoo.mall.common.processor;
import com.secoo.mall.common.core.exception.SystemInternalException;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public abstract class AbsExceptionProcessor implements ExceptionProcessor{
public abstract class AbsExceptionProcessor implements ExceptionProcessor {
public void process(Exception e) throws Exception{
log.warn("warn:",e);
public void process(Exception e) throws Exception {
convertException(e);
throw e;
//如果不进行友好的异常转换,包装为统一的错误异常抛出
log.error("error:", e);
throw new SystemInternalException();
}
protected abstract void convertException(Exception e);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment