Skip to content

Commit

Permalink
refactor: 🎨 增加对自定义异常的处理
Browse files Browse the repository at this point in the history
  • Loading branch information
fxbin committed Nov 22, 2023
1 parent 3aca168 commit 86c736e
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,15 @@ public static <T> Result<T> failure(ErrorCode errorCode) {
return new Result<>(errorCode);
}

/**
* failure
*
* @param exception 例外
* @return {@link Result}<{@link T}>
*/
public static <T> Result<T> failure(ServiceException exception) {
return new Result<>(exception.getErrcode(), exception.getErrmsg());
}

/**
* throwOnFail 当 result 不成功时:直接抛出失败异常,返回传入的 result。
Expand Down

0 comments on commit 86c736e

Please sign in to comment.