jp (pubsub/node/schema): handle not-found conditions properly
This commit is contained in:
parent
968ee50d31
commit
3d112ec965
1 changed files with 20 additions and 14 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue