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

@@ -120,7 +120,11 @@ public class IdentifierComponent implements TlvComponentBase, IEncodingAble {
* @return
*/
public IdentifierComponent(Block block){
this.wireDecode(block);
try {
this.wireDecode(block);
} catch (VlIntException e) {
throw new Error("IdentifierComponent: wireDecode error. "+e.getMessage());
}
}
/**
@@ -177,7 +181,7 @@ public class IdentifierComponent implements TlvComponentBase, IEncodingAble {
* @return
*/
@Override
public int wireEncode(Encoder encoder) {
public int wireEncode(Encoder encoder) throws EncoderException {
return this.identifierBlock.encode(encoder);
}
@@ -187,16 +191,12 @@ public class IdentifierComponent implements TlvComponentBase, IEncodingAble {
* @return
*/
@Override
public boolean wireDecode(Block block) {
public boolean wireDecode(Block block) throws VlIntException {
this.identifierBlock=new Block(block);
//todo:越界问题
int length= 0;
try {
length = this.identifierBlock.getLength().getVlIntValue2Int();
} catch (VlIntException e) {
e.printStackTrace();
}
length = this.identifierBlock.getLength().getVlIntValue2Int();
byte[] value=this.identifierBlock.getValue();
// 要求TLV-LENGTH至少为1,因为 IdentifierComponent 使用 TLV-VALUE 中的第一个字节作为Marker