# HG changeset patch # User Goffi # Date 1605189196 -3600 # Node ID f4d417593e773287e5a0f62fce5c4edf1e2b6291 # Parent 7b4ae3dbc0411eaf40ad3d0a7fc27d6a2a59a5f3 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. diff -r 7b4ae3dbc041 -r f4d417593e77 sat_frontends/jp/cmd_pubsub.py --- a/sat_frontends/jp/cmd_pubsub.py Thu Nov 12 14:53:16 2020 +0100 +++ b/sat_frontends/jp/cmd_pubsub.py Thu Nov 12 14:53:16 2020 +0100 @@ -36,6 +36,7 @@ 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 @@ 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 @@ 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)