From 3d112ec9650287d53238ac77d5d9eac737a03626 Mon Sep 17 00:00:00 2001 From: Goffi Date: Fri, 11 Dec 2020 17:58:36 +0100 Subject: [PATCH] jp (pubsub/node/schema): handle not-found conditions properly --- sat_frontends/jp/cmd_pubsub.py | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/sat_frontends/jp/cmd_pubsub.py b/sat_frontends/jp/cmd_pubsub.py index 12165727..428fea2a 100644 --- a/sat_frontends/jp/cmd_pubsub.py +++ b/sat_frontends/jp/cmd_pubsub.py @@ -668,11 +668,14 @@ class NodeSchemaEdit(base.CommandBase, common.BaseEdit): self.args.node, self.profile, ) - except Exception as e: - self.disp(f"can't edit schema: {e}", error=True) - self.host.quit(C.EXIT_BRIDGE_ERRBACK) - else: - await self.psSchemaGetCb(schema) + except BridgeException as e: + if e.condition == 'item-not-found' or e.classname=="NotFound": + schema = "" + else: + self.disp(f"can't edit schema: {e}", error=True) + self.host.quit(C.EXIT_BRIDGE_ERRBACK) + + await self.psSchemaGetCb(schema) class NodeSchemaGet(base.CommandBase): @@ -698,16 +701,19 @@ class NodeSchemaGet(base.CommandBase): self.args.node, self.profile, ) - except Exception as e: - self.disp(f"can't get schema: {e}", error=True) - self.host.quit(C.EXIT_BRIDGE_ERRBACK) - else: - if schema: - await self.output(schema) - self.host.quit() + except BridgeException as e: + if e.condition == 'item-not-found' or e.classname=="NotFound": + schema = None else: - self.disp(_("no schema found"), 1) - self.host.quit(1) + self.disp(f"can't get schema: {e}", error=True) + self.host.quit(C.EXIT_BRIDGE_ERRBACK) + + if schema: + await self.output(schema) + self.host.quit() + else: + self.disp(_("no schema found"), 1) + self.host.quit(C.EXIT_NOT_FOUND) class NodeSchema(base.CommandBase):