Skip to content

Commit 09eff10

Browse files
committed
tools: rpc_cloud: string format error codes
If a RPC query returns an error code, print the string version of the code as well. Signed-off-by: Jordan Yates <jordan@embeint.com>
1 parent 00f8169 commit 09eff10

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/infuse_iot/tools/rpc_cloud.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from infuse_iot.credentials import get_api_key
2424
from infuse_iot.definitions.rpc import id_type_mapping
2525
from infuse_iot.util.ctypes import UINT32_MAX
26+
from infuse_iot.zephyr.errno import errno
2627

2728

2829
class SubCommand(InfuseCommand):
@@ -125,7 +126,8 @@ def query(self, client: Client):
125126
if downlink.status == DownlinkMessageStatus.COMPLETED:
126127
rpc_rsp = downlink.rpc_rsp
127128
assert isinstance(rpc_rsp, RpcRsp)
128-
print(f" Result: {rpc_rsp.return_code}")
129+
extra = f" ({errno(-rpc_rsp.return_code).name})" if rpc_rsp.return_code < 0 else ""
130+
print(f" Result: {rpc_rsp.return_code}{extra}")
129131
if rpc_rsp.params:
130132
print(json.dumps(rpc_rsp.params.additional_properties, indent=4))
131133
elif rpc_rsp.params_encoded:

0 commit comments

Comments
 (0)