Commit c2c16b9b authored by yanzg's avatar yanzg

错误处理

parent 07a5ecd6
......@@ -162,14 +162,45 @@ public class ResponseResult<T> extends BaseVo {
/**
* 处理错误
*
* @param code
* @param message
* @param target
* @param <T>
* @return
* @param target 错误源对象
* @return 处理的错误
*/
public static final ResponseResult error(Object target) {
return error(ResultConstants.UNKNOW_ERROR, "未知异常", target);
}
/**
* 处理错误
*
* @param code 错误码
* @param message 错误消息
* @return 处理的错误
*/
public static final ResponseResult error(String code, String message) {
return error(code, message, null);
}
/**
* 处理错误
*
* @param message 错误消息
* @param target 错误标记
* @return 处理的错误
*/
public static final ResponseResult error(String message, Object target) {
return error(ResultConstants.UNKNOW_ERROR, message, null);
}
/**
* 处理错误
*
* @param code 错误码
* @param message 错误消息
* @param target 错误标记
* @return 处理的错误
*/
public static final <T extends Object> ResponseResult<T> error(String code, String message, T data, Object target) {
ResponseResult<T> ret = new ResponseResult<>(code, message, data, target);
public static final ResponseResult error(String code, String message, Object target) {
ResponseResult ret = new ResponseResult(code, message, null, target);
return ret;
}
}
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