jp (pubsub/node/info, pubsub/get): better exit code:
the correct exit code is now returned in case of NOT_FOUND or bridge exception. If the exception is not a bridge exception, an internal error exit code is used.
This commit is contained in:
parent
d818f1737b
commit
df6428c14c
1 changed files with 25 additions and 4 deletions
|
|
@ -36,6 +36,7 @@ from sat.tools.common import data_format
|
|||
from sat.tools.common import uri
|
||||
from sat.tools.common.ansi import ANSI as A
|
||||
from sat_frontends.tools import jid, strings
|
||||
from sat_frontends.bridge.bridge_frontend import BridgeException
|
||||
|
||||
__commands__ = ["Pubsub"]
|
||||
|
||||
|
|
@ -80,9 +81,19 @@ class NodeInfo(base.CommandBase):
|
|||
self.args.node,
|
||||
self.profile,
|
||||
)
|
||||
except BridgeException as e:
|
||||
if e.condition == 'item-not-found':
|
||||
self.disp(
|
||||
f"The node {self.args.node} doesn't exist on {self.args.service}",
|
||||
error=True
|
||||
)
|
||||
self.host.quit(C.EXIT_NOT_FOUND)
|
||||
else:
|
||||
self.disp(f"can't get node configuration: {e}", error=True)
|
||||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
except Exception as e:
|
||||
self.disp(f"can't get node configuration: {e}", error=True)
|
||||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
self.disp(f"Internal error: {e}", error=True)
|
||||
self.host.quit(C.EXIT_INTERNAL_ERROR)
|
||||
else:
|
||||
key_filter = (lambda k: True) if not self.args.keys else self.filterKey
|
||||
config_dict = {
|
||||
|
|
@ -815,9 +826,19 @@ class Get(base.CommandBase):
|
|||
self.profile,
|
||||
)
|
||||
)
|
||||
except BridgeException as e:
|
||||
if e.condition == 'item-not-found' or e.classname=="NotFound":
|
||||
self.disp(
|
||||
f"The node {self.args.node} doesn't exist on {self.args.service}",
|
||||
error=True
|
||||
)
|
||||
self.host.quit(C.EXIT_NOT_FOUND)
|
||||
else:
|
||||
self.disp(f"can't get pubsub items: {e}", error=True)
|
||||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
except Exception as e:
|
||||
self.disp(f"can't get pubsub items: {e}", error=True)
|
||||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
self.disp(f"Internal error: {e}", error=True)
|
||||
self.host.quit(C.EXIT_INTERNAL_ERROR)
|
||||
else:
|
||||
await self.output(ps_result['items'])
|
||||
self.host.quit(C.EXIT_OK)
|
||||
|
|
|
|||
Loading…
Reference in a new issue