diff sat_frontends/jp/cmd_pubsub.py @ 3453:864485605d12

jp (pubsub/node/schema): handle not-found conditions properly
author Goffi <goffi@goffi.org>
date Fri, 11 Dec 2020 17:58:36 +0100
parents f4d417593e77
children 5901a7170528
line wrap: on
line diff
--- 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):