Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-api-boot
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-api-boot
Commits
611f6b3f
提交
611f6b3f
authored
7月 26, 2022
作者:
方治民
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 优化 Result、Status、Code 对异常的快速处理实现及示例
上级
6d713222
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
10 行增加
和
4 行删除
+10
-4
Code.java
app/src/main/java/com/yiring/app/constant/Code.java
+1
-1
ExampleController.java
...in/java/com/yiring/app/web/example/ExampleController.java
+1
-2
Status.java
...mon/core/src/main/java/com/yiring/common/core/Status.java
+8
-1
没有找到文件。
app/src/main/java/com/yiring/app/constant/Code.java
浏览文件 @
611f6b3f
...
@@ -56,7 +56,7 @@ public enum Code {
...
@@ -56,7 +56,7 @@ public enum Code {
/**
/**
* 暴露异常
* 暴露异常
*/
*/
public
void
expose
()
{
public
void
expose
()
throws
CodeException
{
throw
exception
();
throw
exception
();
}
}
}
}
app/src/main/java/com/yiring/app/web/example/ExampleController.java
浏览文件 @
611f6b3f
...
@@ -8,7 +8,6 @@ import com.yiring.app.constant.Code;
...
@@ -8,7 +8,6 @@ import com.yiring.app.constant.Code;
import
com.yiring.app.domain.TestTable
;
import
com.yiring.app.domain.TestTable
;
import
com.yiring.app.domain.user.UserExtension
;
import
com.yiring.app.domain.user.UserExtension
;
import
com.yiring.app.domain.user.UserExtensionRepository
;
import
com.yiring.app.domain.user.UserExtensionRepository
;
import
com.yiring.app.exception.CodeException
;
import
com.yiring.app.mapper.TestTableMapper
;
import
com.yiring.app.mapper.TestTableMapper
;
import
com.yiring.app.vo.user.UserExtensionVo
;
import
com.yiring.app.vo.user.UserExtensionVo
;
import
com.yiring.auth.annotation.AuthIgnore
;
import
com.yiring.auth.annotation.AuthIgnore
;
...
@@ -68,7 +67,7 @@ public class ExampleController {
...
@@ -68,7 +67,7 @@ public class ExampleController {
*/
*/
@GetMapping
(
"fail"
)
@GetMapping
(
"fail"
)
public
Result
<
String
>
fail
()
{
public
Result
<
String
>
fail
()
{
throw
new
CodeException
(
Code
.
FAIL
);
throw
Code
.
FAIL
.
exception
(
);
}
}
@GetMapping
(
"page"
)
@GetMapping
(
"page"
)
...
...
basic-common/core/src/main/java/com/yiring/common/core/Status.java
浏览文件 @
611f6b3f
...
@@ -142,6 +142,13 @@ public enum Status {
...
@@ -142,6 +142,13 @@ public enum Status {
/**
/**
* 快速失败异常
* 快速失败异常
*/
public
FailStatusException
exception
()
{
return
exception
(
null
);
}
/**
* 快速失败异常
*
*
* @param message 异常消息
* @param message 异常消息
*/
*/
...
@@ -153,7 +160,7 @@ public enum Status {
...
@@ -153,7 +160,7 @@ public enum Status {
* 暴露异常
* 暴露异常
* @param message 异常消息
* @param message 异常消息
*/
*/
public
void
expose
(
String
message
)
{
public
void
expose
(
String
message
)
throws
FailStatusException
{
throw
exception
(
message
);
throw
exception
(
message
);
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论