plusone-commons 修改了 BaseException
parent
1d4eadaefe
commit
0ea6867856
|
@ -13,7 +13,7 @@ public class BaseValidator<T> {
|
|||
private final List<PropertyValidator<T, ?, ?>> propertyValidators = new ArrayList<>();
|
||||
|
||||
protected void withRule(final Predicate<T> rule, final String errorMessage) {
|
||||
withRule(rule, () -> new InvalidInputException(errorMessage));
|
||||
withRule(rule, () -> InvalidInputException.of(errorMessage));
|
||||
}
|
||||
|
||||
protected <E extends RuntimeException> void withRule(Predicate<T> rule, Supplier<E> exceptionBuilder) {
|
||||
|
|
|
@ -11,29 +11,29 @@ public class InvalidInputException extends BaseException {
|
|||
|
||||
private static final long serialVersionUID = 7956661913360059670L;
|
||||
|
||||
public static final int ERROR_CODE = 4040200;
|
||||
public static final String ERROR_CODE = "4040200";
|
||||
|
||||
private InvalidInputException(int code, String msg) {
|
||||
private InvalidInputException(String code, String msg) {
|
||||
super(code, msg);
|
||||
}
|
||||
|
||||
private InvalidInputException(int code, Throwable cause) {
|
||||
private InvalidInputException(String code, Throwable cause) {
|
||||
super(code, cause);
|
||||
}
|
||||
|
||||
private InvalidInputException(int code, String msg, Throwable cause) {
|
||||
private InvalidInputException(String code, String msg, Throwable cause) {
|
||||
super(code, msg, cause);
|
||||
}
|
||||
|
||||
public InvalidInputException(String msg) {
|
||||
this(ERROR_CODE, msg);
|
||||
public static InvalidInputException of(String msg) {
|
||||
return new InvalidInputException(ERROR_CODE, msg);
|
||||
}
|
||||
|
||||
public InvalidInputException(Throwable cause) {
|
||||
this(ERROR_CODE, cause);
|
||||
public static InvalidInputException of(Throwable cause) {
|
||||
return new InvalidInputException(ERROR_CODE, cause);
|
||||
}
|
||||
|
||||
public InvalidInputException(String msg, Throwable cause) {
|
||||
this(ERROR_CODE, msg, cause);
|
||||
public static InvalidInputException of(String msg, Throwable cause) {
|
||||
return new InvalidInputException(ERROR_CODE, msg, cause);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ abstract class PropertyValidator<DTO, PROPERTY, THIS> {
|
|||
// ===== equals =====
|
||||
|
||||
public THIS equalsThat(Object that) {
|
||||
return equalsThat(that, value -> new InvalidInputException(String.format("(%s) 必须与 (%s) 相等", value, that)));
|
||||
return equalsThat(that, value -> InvalidInputException.of(String.format("(%s) 必须与 (%s) 相等", value, that)));
|
||||
}
|
||||
|
||||
public THIS equalsThat(Object that, String errMsg) {
|
||||
|
@ -143,7 +143,7 @@ abstract class PropertyValidator<DTO, PROPERTY, THIS> {
|
|||
}
|
||||
|
||||
static <V> Function<V, InvalidInputException> convertExceptionCreator(String errMsg) {
|
||||
return value -> new InvalidInputException(errMsg);
|
||||
return value -> InvalidInputException.of(errMsg);
|
||||
}
|
||||
|
||||
static <V, E extends RuntimeException> Function<V, E> convertExceptionCreator(
|
||||
|
|
Loading…
Reference in New Issue