use of com.dq.easy.cloud.module.basic.pojo.dto.DqBaseServiceResult in project dq-easy-cloud by dq-open-cloud.
the class DqBaseBusinessException method getMessage.
@Override
public String getMessage() {
DqBaseServiceResult result = null;
if (DqBaseUtils.isNull(dqBaseErrorCodeInf)) {
result = DqBaseServiceResult.newInstance();
result.setErrorCode(errorCode);
result.setErrorMsg(errorMsg);
} else {
result = DqBaseServiceResult.newInstanceOfError(dqBaseErrorCodeInf);
}
result.buildResult(exceptionDetail);
return DqJSONUtils.parseObject(result, String.class);
}
use of com.dq.easy.cloud.module.basic.pojo.dto.DqBaseServiceResult in project dq-easy-cloud by dq-open-cloud.
the class DqBaseExceptionHandle method handleAndReturnData.
/**
* 基于@ExceptionHandler异常处理
*/
@ExceptionHandler
@ResponseBody
public DqBaseServiceResult handleAndReturnData(HttpServletRequest request, HttpServletResponse response, Exception ex) {
logger.error(ex.getMessage(), ex);
DqBaseServiceResult dqBaseServiceResult = DqBaseServiceResult.newInstance();
DqBaseServiceResultException serviceResultException = DqBaseServiceResultException.newInstance();
String path = request.getRequestURL().toString();
if (ex instanceof DqBaseBusinessException) {
DqBaseBusinessException dbbException = (DqBaseBusinessException) ex;
dqBaseServiceResult.buildErrorCodeAndMsg(dbbException.getErrorCode(), dbbException.getErrorMsg());
} else if (ex instanceof RuntimeException) {
dqBaseServiceResult.buildDqBaseErrorCodeInf(DqBaseErrorCodeEnum.RUNTIME_EXCEPTION);
} else {
dqBaseServiceResult.buildDqBaseErrorCodeInf(DqBaseErrorCodeEnum.SYS_EXCEPTION);
}
serviceResultException.setException(ex.getClass().getName());
serviceResultException.setFailureDetails(ex.getMessage());
serviceResultException.setTimstamp(DqDateUtils.getCurrentDate());
serviceResultException.setPath(path);
dqBaseServiceResult.buildServiceResultException(serviceResultException);
DqLogUtils.error("异常统一处理日志", dqBaseServiceResult, logger);
return dqBaseServiceResult;
}
Aggregations