Skip to content

Commit 8228ed6

Browse files
committed
修改错误提示
1 parent 0ecc2c1 commit 8228ed6

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

platform-yml-parser/src/main/java/com/flow/platform/yml/parser/YmlParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class YmlParser {
3434

3535
private final static YamlConfig yamlConfig = new YamlConfig();
3636

37-
private final static String YML_ILLEGAL_MESSAGE = "Yml illegal format, please confirm yml format";
37+
private final static String YML_ILLEGAL_MESSAGE = "yml format is illegal";
3838
private final static String YML_CONVERT_MESSAGE = "Object to yml error, please retry";
3939

4040
static {

platform-yml-parser/src/main/java/com/flow/platform/yml/parser/adaptor/YmlAdaptor.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.lang.reflect.Field;
2828
import java.lang.reflect.Method;
2929
import java.lang.reflect.Type;
30-
import java.util.HashMap;
3130
import java.util.LinkedHashMap;
3231
import java.util.Map;
3332

@@ -65,7 +64,7 @@ protected <T> T doRead(Object o, Class<T> clazz) {
6564
try {
6665
instance = clazz.newInstance();
6766
} catch (Throwable throwable) {
68-
throw new YmlParseException(String.format("clazz - %s instance error", clazz.getName()), throwable);
67+
throw new YmlParseException(String.format("clazz '%s' create instance error ", clazz.getName()), throwable);
6968
}
7069

7170
Class<?> raw = clazz;
@@ -122,7 +121,7 @@ private <T> void setValueToField(Object o, Field field, T instance, YmlSerialize
122121
// required field
123122
if (requiredField(ymlSerializer)) {
124123
if (obj == null) {
125-
throw new YmlParseException(String.format("required field - %s , please confirm", field.getName()));
124+
throw new YmlParseException(String.format("field '%s' is missing", field.getName()));
126125
}
127126
}
128127

@@ -163,7 +162,7 @@ protected <T> Object doWrite(Field field, T t, YmlSerializer ymlSerializer) {
163162
try {
164163
return TypeAdaptorFactory.getAdaptor(fieldType).write(field.get(t));
165164
} catch (Throwable throwable) {
166-
throw new YmlParseException(String.format("field - %s get error", field.getName()), throwable);
165+
throw new YmlParseException(String.format("field '%s' is get error", field.getName()), throwable);
167166
}
168167
}
169168

@@ -174,7 +173,7 @@ protected <T> Object doWrite(Field field, T t, YmlSerializer ymlSerializer) {
174173
return instance.write(field.get(t));
175174
} catch (Throwable throwable) {
176175
throw new YmlParseException(
177-
String.format("create instance adaptor - %s error", ymlSerializer.adaptor().getName()), throwable);
176+
String.format("create instance '%s' adaptor error", ymlSerializer.adaptor().getName()), throwable);
178177
}
179178
}
180179

@@ -193,11 +192,12 @@ public static <T> void validate(Field field, T instance, YmlSerializer ymlSerial
193192
value = field.get(instance);
194193
} catch (Throwable throwable) {
195194
throw new YmlFormatException(String
196-
.format("validate - %s instance error - %s", ymlSerializer.validator().getName(), throwable));
195+
.format("field '%s' is validate error %s", ymlSerializer.validator().getName(),
196+
throwable.getMessage()));
197197
}
198198

199199
if (validator.validate(value) == false) {
200-
throw new YmlFormatException(String.format("field - %s , validate - error", field.getName()));
200+
throw new YmlFormatException(String.format("field '%s' is validate error", field.getName()));
201201
}
202202

203203
}

platform-yml-parser/src/main/java/com/flow/platform/yml/parser/exception/YmlException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
public class YmlException extends RuntimeException {
2323

2424
public YmlException(String message) {
25-
super(message);
25+
super(String.format("Illegal yml format: %s", message));
2626
}
2727

2828
public YmlException(String message, Throwable cause) {
29-
super(message, cause);
29+
super(String.format("Illegal yml format: %s", message), cause);
3030
}
3131
}

0 commit comments

Comments
 (0)