jp (pubsub/node/schema): handle not-found conditions properly

This commit is contained in:
Goffi 2020-12-11 17:58:36 +01:00
commit 3d112ec965

View file

@ -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):