# HG changeset patch # User Goffi # Date 1607705916 -3600 # Node ID 864485605d1243d5ee37e458d48b8c0f5894cc2f # Parent bb0225aaf4e6137099ce902f87fbc188e4a62b74 jp (pubsub/node/schema): handle not-found conditions properly diff -r bb0225aaf4e6 -r 864485605d12 sat_frontends/jp/cmd_pubsub.py --- a/sat_frontends/jp/cmd_pubsub.py Fri Dec 11 17:57:00 2020 +0100 +++ b/sat_frontends/jp/cmd_pubsub.py Fri Dec 11 17:58:36 2020 +0100 @@ -668,11 +668,14 @@ 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 @@ 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) + except BridgeException as e: + if e.condition == 'item-not-found' or e.classname=="NotFound": + schema = None + else: + 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: - if schema: - await self.output(schema) - self.host.quit() - else: - self.disp(_("no schema found"), 1) - self.host.quit(1) + self.disp(_("no schema found"), 1) + self.host.quit(C.EXIT_NOT_FOUND) class NodeSchema(base.CommandBase):