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

+11 -11
View File
@@ -27,7 +27,7 @@ public class SignatureValue implements TlvComponentBase, IEncodingAble {
* 根据 TLV Block 创建一个 SignatureValue
* @param block
*/
public SignatureValue(Block block){
public SignatureValue(Block block) throws VlIntException {
this.buildSignatureValueByBlock(block);
}
@@ -47,7 +47,7 @@ public class SignatureValue implements TlvComponentBase, IEncodingAble {
* @param block
* @return
*/
public boolean buildSignatureValueByBlock(Block block){
public boolean buildSignatureValueByBlock(Block block) throws VlIntException {
return this.wireDecode(block);
}
@@ -65,26 +65,26 @@ public class SignatureValue implements TlvComponentBase, IEncodingAble {
* @return
*/
@Override
public int wireEncode(Encoder encoder) {
public int wireEncode(Encoder encoder) throws EncoderException {
int totalLength=0;
// 编码 TLV-VALUE
int tmplen=encoder.prependByteArray(this.value,new SizeT(this.value.length));
if(tmplen<=0){
return 0;
return -1;
}
totalLength+=tmplen;
// 编码 TLV-LENGTH
tmplen=encoder.prependVarNumber(new VlInt(totalLength));
if(tmplen<=0){
return 0;
return -1;
}
totalLength+=tmplen;
// 编码 TLV-TYPE
tmplen=encoder.prependVarNumber(new VlInt(TLV.TlvSignatureValue));
if(tmplen<=0){
return 0;
return -1;
}
totalLength+=tmplen;
@@ -97,18 +97,18 @@ public class SignatureValue implements TlvComponentBase, IEncodingAble {
* @return
*/
@Override
public boolean wireDecode(Block block) {
public boolean wireDecode(Block block) throws VlIntException {
// 检查 Type 是否正确
if(!TLV.expectType(block.getType(),new VlInt(TLV.TlvSignatureValue))){
return false;
}
int len= 0;
try {
// try {
len = block.getLength().getVlIntValue2Int();
} catch (VlIntException e) {
e.printStackTrace();
}
// } catch (VlIntException e) {
// e.printStackTrace();
// }
this.value=new byte[len];
System.arraycopy(block.getValue(),0,this.value,0,len);
return true;