lnbase: do not catch all exceptions, tolerate calculations with variables from kwargs
This commit is contained in:
parent
b64e97a68b
commit
fe7d1ccd7f
@ -97,8 +97,10 @@ def gen_msg(msg_type, **kwargs):
|
|||||||
poslenMap = typ["payload"][k]
|
poslenMap = typ["payload"][k]
|
||||||
leng = calcexp(poslenMap["length"], lengths)
|
leng = calcexp(poslenMap["length"], lengths)
|
||||||
try:
|
try:
|
||||||
leng = kwargs[poslenMap["length"]]
|
clone = dict(lengths)
|
||||||
except:
|
clone.update(kwargs)
|
||||||
|
leng = calcexp(poslenMap["length"], clone)
|
||||||
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
param = kwargs[k]
|
param = kwargs[k]
|
||||||
@ -106,7 +108,7 @@ def gen_msg(msg_type, **kwargs):
|
|||||||
param = 0
|
param = 0
|
||||||
try:
|
try:
|
||||||
param = param.to_bytes(length=leng, byteorder="big")
|
param = param.to_bytes(length=leng, byteorder="big")
|
||||||
except:
|
except ValueError:
|
||||||
raise Exception("{} does not fit in {} bytes".format(k, leng))
|
raise Exception("{} does not fit in {} bytes".format(k, leng))
|
||||||
lengths[k] = len(param)
|
lengths[k] = len(param)
|
||||||
data += param
|
data += param
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user