error handle to all: VlIntException

This commit is contained in:
free will committed 2021-03-18 20:12:27 +08:00
1 parent 96650c8f42
commit 30dd00ffb4
5 files changed
+21 -20

No files matched your search

+1 -1
View File
@@ -147,7 +147,7 @@ public class SignatureField 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.TlvSignatureField))){
return false;
+4 -4
View File
@@ -38,7 +38,7 @@ public class SignatureInfo implements TlvComponentBase, IEncodingAble {
* 根据 TLV Block 创建一个 SignatureInfo
* @param block
*/
public SignatureInfo(Block block){
public SignatureInfo(Block block) throws VlIntException {
this.buildSignatureInfoByBlock(block);
}
@@ -74,7 +74,7 @@ public class SignatureInfo implements TlvComponentBase, IEncodingAble {
* @param block
* @return
*/
public boolean buildSignatureInfoByBlock(Block block){
public boolean buildSignatureInfoByBlock(Block block) throws VlIntException {
return this.wireDecode(block);
}
@@ -127,7 +127,7 @@ public class SignatureInfo implements TlvComponentBase, IEncodingAble {
// 编码 TLV-TYPE
tmplen=encoder.prependVarNumber(new VlInt(TLV.TlvSignatureInfo));
if(tmplen<=0){
return 0;
return -1;
}
totalLength+=tmplen;
@@ -140,7 +140,7 @@ public class SignatureInfo 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.TlvSignatureInfo))){
return false;
+8 -8
View File
@@ -37,7 +37,7 @@ public class MINPacket implements IEncodingAble {
@Override
public int wireEncode(Encoder encoder) throws EncoderException {
if(!this.isPacketValid()){
return 0;
return -1;
}
int totalLength=0;
@@ -46,42 +46,42 @@ public class MINPacket implements IEncodingAble {
// 可变区
int tmplen=this.mutableField.wireEncode(encoder);
if(tmplen<=0){
return 0;
return -1;
}
totalLength+=tmplen;
// 只读区
tmplen=this.readOnlyField.wireEncode(encoder);
if(tmplen<=0){
return 0;
return -1;
}
totalLength+=tmplen;
// 签名区
tmplen=this.signatureField.wireEncode(encoder);
if(tmplen<=0){
return 0;
return -1;
}
totalLength+=tmplen;
// 标识区
tmplen=this.identifierField.wireEncode(encoder);
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(this.packetType);
if(tmplen<=0){
return 0;
return -1;
}
totalLength+=tmplen;
@@ -98,7 +98,7 @@ public class MINPacket implements IEncodingAble {
* @return
*/
@Override
public boolean wireDecode(Block block) {
public boolean wireDecode(Block block) throws VlIntException {
// 首先判断包是否有效
if(!block.isValid()){
return false;