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
@@ -43,27 +43,27 @@ public class CongestionMark implements TlvComponentBase,InitialAble, IEncodingAb
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int wireEncode(Encoder encoder) {
|
||||
public int wireEncode(Encoder encoder) throws EncoderException {
|
||||
int totalLength=0;
|
||||
|
||||
// 编码 TLV-VALUE
|
||||
int tmplen=encoder.prependNonNegativeInteger(this.congestionMark);
|
||||
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.TlvCongestionMark));
|
||||
if(tmplen==0){
|
||||
return 0;
|
||||
if(tmplen<=0){
|
||||
return -1;
|
||||
}
|
||||
totalLength+=tmplen;
|
||||
|
||||
@@ -76,7 +76,7 @@ public class CongestionMark implements TlvComponentBase,InitialAble, IEncodingAb
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean wireDecode(Block block) {
|
||||
public boolean wireDecode(Block block) throws VlIntException {
|
||||
// 检查 Type 是否正确
|
||||
if(!TLV.expectType(block.getType(),new VlInt(TLV.TlvCongestionMark))){
|
||||
return false;
|
||||
@@ -84,11 +84,7 @@ public class CongestionMark implements TlvComponentBase,InitialAble, IEncodingAb
|
||||
|
||||
// 读取 CongestionMark
|
||||
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