refactor(exception): 将内部异常类抽取为公共异常类
将 SimpleServiceSupport 中的静态内部异常类抽取到 common 模块的独立异常类文件中,包括: - IdNotFoundException: ID 未找到异常 - NotComparableException: 不可比较异常 - NotCollectionException: 非集合异常 - NotStringException: 非字符串异常
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.lanyuanxiaoyao.service.template.common.exception;
|
||||
|
||||
public class NotCollectionException extends RuntimeException {
|
||||
public NotCollectionException(String variable) {
|
||||
super("变量 %s 不是集合".formatted(variable));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.lanyuanxiaoyao.service.template.common.exception;
|
||||
|
||||
public class NotComparableException extends RuntimeException {
|
||||
public NotComparableException(String variable) {
|
||||
super("变量 %s 不能比较".formatted(variable));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.lanyuanxiaoyao.service.template.common.exception;
|
||||
|
||||
public class NotStringException extends RuntimeException {
|
||||
public NotStringException(String variable) {
|
||||
super("变量 %s 不是字符串".formatted(variable));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user