mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
error handle to all: EncoderException
This commit is contained in:
1 parent
5fc080ca6c
commit
8cf6ed24c9
34 files changed
+700
-233
No files matched your search
@@ -53,27 +53,27 @@ public class Nonce implements TlvComponentBase,InitialAble, IEncodingAble {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int wireEncode(Encoder encoder) {
|
||||
public int wireEncode(Encoder encoder) throws EncoderException {
|
||||
int totalLength=0;
|
||||
|
||||
// 编码 TLV-VALUE
|
||||
int tmplen=encoder.prependNonNegativeInteger(this.nonce);
|
||||
if(tmplen==0){
|
||||
return 0;
|
||||
if(tmplen<=0){
|
||||
return -1;
|
||||
}
|
||||
totalLength+=tmplen;
|
||||
|
||||
// 编码 TLV-LENGTH
|
||||
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.TlvNonce));
|
||||
if(tmplen==0){
|
||||
return 0;
|
||||
if(tmplen<=0){
|
||||
return -1;
|
||||
}
|
||||
totalLength+=tmplen;
|
||||
|
||||
@@ -86,7 +86,7 @@ public class Nonce implements TlvComponentBase,InitialAble, IEncodingAble {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean wireDecode(Block block) {
|
||||
public boolean wireDecode(Block block) throws VlIntException {
|
||||
// 检查 Type 是否正确
|
||||
if(!TLV.expectType(block.getType(),new VlInt(TLV.TlvNonce))){
|
||||
return false;
|
||||
@@ -94,11 +94,7 @@ public class Nonce implements TlvComponentBase,InitialAble, IEncodingAble {
|
||||
|
||||
// 读取 value
|
||||
long value= 0;
|
||||
try {
|
||||
value = TLV.readNonNegativeInteger(block.getValue(),0,block.getLength().getVlIntValue2Int());
|
||||
} catch (VlIntException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
value = TLV.readNonNegativeInteger(block.getValue(),0,block.getLength().getVlIntValue2Int());
|
||||
if(value<0){
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user