public <SubClass extends BaseResult> SubClass withErrorAndLog( String inputParamWhereCatch, Throwable e) { return withErrorAndLog( UnknownErrorCodeConstant.exceptionCanRetry, UnknownErrorCodeConstant.getMsg(UnknownErrorCodeConstant.exceptionCanRetry), inputParamWhereCatch, e); }
/** * @param errorCode 定义规范 errorCode 英文,不超过50长度,以“点”分隔,:“粗模块.细模块.错误意思" errorCode规范详见 * http://wiki.inzwc.com/wiki/index.php/AicaiAppModel#errorCode.E6.A0.BC.E5.BC.8F * @param errorMsg */ public <SubClass extends BaseResult> SubClass withError(String errorCode) { String msg = UnknownErrorCodeConstant.getMsg(errorCode); if (msg == null) { msg = "遇到错误[" + errorCode + "],请截屏后告知客服检查或自行重试"; } errorList.put(errorCode, msg); return (SubClass) this; }
/** * 为false则表示业务请求没通过或发生系统异常。 为true则表示肯定没发生系统异常,但业务请求的成功与否还看具体接口定义/javadoc说明,或更多的字段 * * @return */ public boolean isSuccess() { if (!loggedException && detailStack != null) { log.error("{inputParamWhereCatch:'" + inputParamWhereCatch + "'}\r\n" + detailStack); loggedException = true; } if (!loggedWarn && !warnList.isEmpty()) { log.warn("{warnList:'" + warnList.toString() + "'}"); loggedWarn = true; } boolean isEmpty = errorList.isEmpty(); if (!isEmpty) { for (Map.Entry<String, String> entry : errorList.entrySet()) { String msg = UnknownErrorCodeConstant.getMsg(entry.getKey()); if (msg != null) { entry.setValue(msg); } } } return isEmpty; }
/** * @param errorCode 定义规范 errorCode 英文,不超过50长度,以“点”分隔,:“粗模块.细模块.错误意思" errorCode规范详见 * http://wiki.inzwc.com/wiki/index.php/AicaiAppModel#errorCode.E6.A0.BC.E5.BC.8F * @param errorMsg */ public <SubClass extends BaseResult> SubClass withErrorAndLog( String errorCode, String inputParamWhereCatch, Throwable e) { return withErrorAndLog( errorCode, UnknownErrorCodeConstant.getMsg(errorCode), inputParamWhereCatch, e); }