From 86c736e1929a27f2b757107e1a3d819fa2518474 Mon Sep 17 00:00:00 2001 From: fxbin Date: Wed, 22 Nov 2023 16:42:42 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20:art:=20=E5=A2=9E=E5=8A=A0=E5=AF=B9?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=BC=82=E5=B8=B8=E7=9A=84=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/fxbin/bubble/core/dataobject/Result.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bubble-core/src/main/java/cn/fxbin/bubble/core/dataobject/Result.java b/bubble-core/src/main/java/cn/fxbin/bubble/core/dataobject/Result.java index d59767b9..e46c161e 100644 --- a/bubble-core/src/main/java/cn/fxbin/bubble/core/dataobject/Result.java +++ b/bubble-core/src/main/java/cn/fxbin/bubble/core/dataobject/Result.java @@ -229,6 +229,15 @@ public static Result failure(ErrorCode errorCode) { return new Result<>(errorCode); } + /** + * failure + * + * @param exception 例外 + * @return {@link Result}<{@link T}> + */ + public static Result failure(ServiceException exception) { + return new Result<>(exception.getErrcode(), exception.getErrmsg()); + } /** * throwOnFail 当 result 不成功时:直接抛出失败异常,返回传入的 result。