Skip to content

Commit bdf92ca

Browse files
authored
Merge pull request #60 from ad19900913/master
完善数据序列化与反序列化时的错误提示
2 parents 4a8268f + 4857649 commit bdf92ca

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

rdf-file-core/src/main/java/com/alipay/rdf/file/codec/RowColumnHorizontalCodec.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ public static String serialize(BeanMapWrapper bmw, FileConfig fileConfig, RowDef
5555
}
5656

5757
for (int i = 0; i < columnMetas.size(); i++) {
58+
FileColumnMeta columnMeta = columnMetas.get(i);
59+
FuncContext ctx = new FuncContext();
5860
try {
59-
FileColumnMeta columnMeta = columnMetas.get(i);
60-
FuncContext ctx = new FuncContext();
6161
ctx.codecType = CodecType.SERIALIZE;
6262
ctx.field = bmw.getProperty(columnMeta.getName());
6363
ctx.columnMeta = columnMeta;
@@ -71,13 +71,13 @@ public static String serialize(BeanMapWrapper bmw, FileConfig fileConfig, RowDef
7171
} catch (RdfFileException e) {
7272
throw new RdfFileException(
7373
"rdf-file#RowColumnHorizontalCodec.serialize serialize row=" + bmw.getBean()
74-
+ ", fileConfig=" + fileConfig + ", 将数据序列到文件出错."
74+
+ ", fileConfig=" + fileConfig + ", 将数据序列到文件出错. 错误列信息: columnMeta=" + columnMeta + ", field=" + ctx.field + ", errorMsg="
7575
+ e.getMessage(),
7676
e, e.getErrorEnum());
7777
} catch (Throwable e) {
7878
throw new RdfFileException(
7979
"rdf-file#RowColumnHorizontalCodec.serialize row=" + bmw.getBean()
80-
+ ", fileConfig=" + fileConfig + ", 将数据序列到文件出错.",
80+
+ ", fileConfig=" + fileConfig + ", 将数据序列到文件出错. 错误列信息: columnMeta=" + columnMeta + ", field=" + ctx.field,
8181
e, RdfErrorEnum.SERIALIZE_ERROR);
8282
}
8383
}
@@ -124,9 +124,9 @@ public static <T> T deserialize(BeanMapWrapper bmw, FileConfig fileConfig, Strin
124124
int endIndex = fileMeta.isEndWithSplit(rowType) ? column.length - 1 : column.length;
125125

126126
for (int i = statIndex; i < endIndex; i++) {
127+
FileColumnMeta columnMeta = columnMetas.get(i - statIndex);
128+
FuncContext ctx = new FuncContext();
127129
try {
128-
FileColumnMeta columnMeta = columnMetas.get(i - statIndex);
129-
FuncContext ctx = new FuncContext();
130130
ctx.codecType = CodecType.DESERIALIZE;
131131
ctx.field = column[i];
132132
ctx.columnMeta = columnMeta;
@@ -135,11 +135,12 @@ public static <T> T deserialize(BeanMapWrapper bmw, FileConfig fileConfig, Strin
135135
} catch (RdfFileException e) {
136136
throw new RdfFileException(
137137
"rdf-file#RowColumnHorizontalCodec.deserialize line=" + line + ", fileConfig="
138-
+ fileConfig + ", 将数据反序列到对象出错. " + e.getMessage(),
138+
+ fileConfig + ", 将数据反序列到对象出错. 错误列信息:field=" + ctx.field + ", columnMeta=" + columnMeta + ", errorMsg="
139+
+ e.getMessage(),
139140
e, e.getErrorEnum());
140141
} catch (Throwable e) {
141142
throw new RdfFileException("rdf-file#RowColumnHorizontalCodec.deserialize line="
142-
+ line + ", fileConfig=" + fileConfig + ", 将数据反序列到对象出错.",
143+
+ line + ", fileConfig=" + fileConfig + ", 将数据反序列到对象出错. 错误列信息:field=" + ctx.field + ", columnMeta=" + columnMeta,
143144
e, RdfErrorEnum.DESERIALIZE_ERROR);
144145
}
145146
}

0 commit comments

Comments
 (0)