error handle to all: EncoderException

This commit is contained in:
free will committed 2021-03-18 11:22:49 +08:00
1 parent 5fc080ca6c
commit 8cf6ed24c9
34 files changed
+700 -233

No files matched your search

+7 -7
View File
@@ -57,7 +57,7 @@ public class ReadOnlyField implements TlvComponentBase, IEncodingAble {
* @return
*/
@Override
public int wireEncode(Encoder encoder) {
public int wireEncode(Encoder encoder) throws EncoderException {
// 如果只读区没有任何子 TLV,则可以去掉只读区 TLV
if(this.blocks.length()==0){
return 0;
@@ -68,23 +68,23 @@ public class ReadOnlyField implements TlvComponentBase, IEncodingAble {
// 反向遍历,可以保证解码的时候正向输出
for(int i=this.blocks.length()-1;i>=0;i++){
int tmplen=encoder.prependBlock(this.blocks.getBlock(i));
if(tmplen==0){
return 0;
if(tmplen<=0){
return -1;
}
totalLength+=tmplen;
}
// 编码 TLV-LENGTH
int tmplen=encoder.prependVarNumber(new VlInt(totalLength));
if(tmplen==0){
return 0;
if(tmplen<=0){
return -1;
}
totalLength+=tmplen;
// 编码 TLV-TYPE
tmplen=encoder.prependVarNumber(new VlInt(TLV.TlvReadOnlyField));
if(tmplen==0){
return 0;
if(tmplen<=0){
return -1;
}
totalLength+=tmplen;