mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +01:00
Fixed raising TypeError instead of ValueError when there is an invalid type.
This commit is contained in:
parent
a005ec1e84
commit
a35006e701
5 changed files with 7 additions and 7 deletions
|
@ -75,7 +75,7 @@ def gen_field(field):
|
|||
elif isinstance(field, PrimitiveField):
|
||||
return gen_primitive(field)
|
||||
else:
|
||||
raise ValueError(f"Unmanaged type {field}")
|
||||
raise TypeError(f"Unmanaged type {field}")
|
||||
|
||||
|
||||
def gen_enum(e):
|
||||
|
|
|
@ -152,7 +152,7 @@ class GossmapNodeId(object):
|
|||
|
||||
def __lt__(self, other):
|
||||
if not isinstance(other, GossmapNodeId):
|
||||
raise ValueError(f"Cannot compare GossmapNodeId with {type(other)}")
|
||||
raise TypeError(f"Cannot compare GossmapNodeId with {type(other)}")
|
||||
return self.nodeid.__lt__(other.nodeid) # yes, that works
|
||||
|
||||
def __hash__(self):
|
||||
|
@ -268,7 +268,7 @@ class GossmapNode(object):
|
|||
|
||||
def __lt__(self, other):
|
||||
if not isinstance(other, GossmapNode):
|
||||
raise ValueError(f"Cannot compare GossmapNode with {type(other)}")
|
||||
raise TypeError(f"Cannot compare GossmapNode with {type(other)}")
|
||||
return self.node_id.__lt__(other.node_id)
|
||||
|
||||
def __hash__(self):
|
||||
|
|
|
@ -411,7 +411,7 @@ class UnixDomainSocketRpc(object):
|
|||
sock.close()
|
||||
|
||||
if not isinstance(resp, dict):
|
||||
raise ValueError("Malformed response, response is not a dictionary %s." % resp)
|
||||
raise TypeError("Malformed response, response is not a dictionary %s." % resp)
|
||||
elif "error" in resp:
|
||||
raise RpcError(method, payload, resp['error'])
|
||||
elif "result" not in resp:
|
||||
|
|
|
@ -949,14 +949,14 @@ class Plugin(object):
|
|||
def verify_str(d: Dict[str, JSONType], key: str) -> str:
|
||||
v = d.get(key)
|
||||
if not isinstance(v, str):
|
||||
raise ValueError("Wrong argument to init: expected {key} to be"
|
||||
raise TypeError("Wrong argument to init: expected {key} to be"
|
||||
" a string, got {v}".format(key=key, v=v))
|
||||
return v
|
||||
|
||||
def verify_bool(d: Dict[str, JSONType], key: str) -> bool:
|
||||
v = d.get(key)
|
||||
if not isinstance(v, bool):
|
||||
raise ValueError("Wrong argument to init: expected {key} to be"
|
||||
raise TypeError("Wrong argument to init: expected {key} to be"
|
||||
" a bool, got {v}".format(key=key, v=v))
|
||||
return v
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ class PublicKey(object):
|
|||
)
|
||||
|
||||
elif not isinstance(innerkey, coincurve.keys.PublicKey):
|
||||
raise ValueError(
|
||||
raise TypeError(
|
||||
"Key must either be bytes or coincurve.keys.PublicKey"
|
||||
)
|
||||
self.key = innerkey
|
||||
|
|
Loading…
Add table
Reference in a new issue