mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
add error handle: ComponentException & PacketException
This commit is contained in:
1 parent
d7f063cbb9
commit
7bf0906291
35 files changed
+955
-362
No files matched your search
@@ -43,7 +43,7 @@ public class CanBePrefix implements TlvComponentBase,InitialAble, IEncodingAble
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int wireEncode(Encoder encoder) throws EncoderException {
|
||||
public int wireEncode(Encoder encoder) throws ComponentException {
|
||||
// 这是一个存在性组件,所以如果值为false,则无需编码
|
||||
if(!this.canBePrefix){
|
||||
return -1;
|
||||
@@ -52,14 +52,23 @@ public class CanBePrefix implements TlvComponentBase,InitialAble, IEncodingAble
|
||||
int totalLength=0;
|
||||
|
||||
// 编码 TLV-LENGTH
|
||||
int tmplen=encoder.prependVarNumber(new VlInt(totalLength));
|
||||
int tmplen= 0;
|
||||
try {
|
||||
tmplen = encoder.prependVarNumber(new VlInt(totalLength));
|
||||
} catch (EncoderException e) {
|
||||
throw new ComponentException("CanBePrefix.wireEncode: "+e.getMessage());
|
||||
}
|
||||
if(tmplen<=0){
|
||||
return -1;
|
||||
}
|
||||
totalLength+=tmplen;
|
||||
|
||||
// 编码 TLV-TYPE
|
||||
tmplen=encoder.prependVarNumber(new VlInt(TLV.TlvCanBePrefix));
|
||||
try {
|
||||
tmplen=encoder.prependVarNumber(new VlInt(TLV.TlvCanBePrefix));
|
||||
} catch (EncoderException e) {
|
||||
throw new ComponentException("CanBePrefix.wireEncode: "+e.getMessage());
|
||||
}
|
||||
if(tmplen<=0){
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user