提交 611f6b3f 作者: 方治民

feat: 优化 Result、Status、Code 对异常的快速处理实现及示例

上级 6d713222
......@@ -56,7 +56,7 @@ public enum Code {
/**
* 暴露异常
*/
public void expose() {
public void expose() throws CodeException {
throw exception();
}
}
......@@ -8,7 +8,6 @@ import com.yiring.app.constant.Code;
import com.yiring.app.domain.TestTable;
import com.yiring.app.domain.user.UserExtension;
import com.yiring.app.domain.user.UserExtensionRepository;
import com.yiring.app.exception.CodeException;
import com.yiring.app.mapper.TestTableMapper;
import com.yiring.app.vo.user.UserExtensionVo;
import com.yiring.auth.annotation.AuthIgnore;
......@@ -68,7 +67,7 @@ public class ExampleController {
*/
@GetMapping("fail")
public Result<String> fail() {
throw new CodeException(Code.FAIL);
throw Code.FAIL.exception();
}
@GetMapping("page")
......
......@@ -142,6 +142,13 @@ public enum Status {
/**
* 快速失败异常
*/
public FailStatusException exception() {
return exception(null);
}
/**
* 快速失败异常
*
* @param message 异常消息
*/
......@@ -153,7 +160,7 @@ public enum Status {
* 暴露异常
* @param message 异常消息
*/
public void expose(String message) {
public void expose(String message) throws FailStatusException {
throw exception(message);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论