1
0

refactor(exception): 将内部异常类抽取为公共异常类

将 SimpleServiceSupport 中的静态内部异常类抽取到 common 模块的独立异常类文件中,包括:
- IdNotFoundException: ID 未找到异常
- NotComparableException: 不可比较异常
- NotCollectionException: 非集合异常
- NotStringException: 非字符串异常
This commit is contained in:
2026-01-07 11:17:03 +08:00
parent 5bf6e9ecdc
commit d08f9db9ac
5 changed files with 32 additions and 68 deletions

View File

@@ -0,0 +1,7 @@
package com.lanyuanxiaoyao.service.template.common.exception;
public class IdNotFoundException extends RuntimeException {
public IdNotFoundException(Long id) {
super("ID为 %d 的资源不存在".formatted(id));
}
}

View File

@@ -0,0 +1,7 @@
package com.lanyuanxiaoyao.service.template.common.exception;
public class NotCollectionException extends RuntimeException {
public NotCollectionException(String variable) {
super("变量 %s 不是集合".formatted(variable));
}
}

View File

@@ -0,0 +1,7 @@
package com.lanyuanxiaoyao.service.template.common.exception;
public class NotComparableException extends RuntimeException {
public NotComparableException(String variable) {
super("变量 %s 不能比较".formatted(variable));
}
}

View File

@@ -0,0 +1,7 @@
package com.lanyuanxiaoyao.service.template.common.exception;
public class NotStringException extends RuntimeException {
public NotStringException(String variable) {
super("变量 %s 不是字符串".formatted(variable));
}
}