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

@@ -57,10 +57,10 @@ public class MutableDangerousField 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;
return -1;
}
int totalLength=0;
@@ -68,23 +68,23 @@ public class MutableDangerousField 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;