Skip to contentSkip to conversation

wic/engine: lets display an error not a traceback

PATCH New Armin Kuster 1 participant 1 message Mar 2, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wic/engine: lets display an error not a traceback

If the requested partition does not exist in this request "wic ls {path}:pnum" display a nice message not a trackback

Also fix displaying the pnum and not "%s"

---
 scripts/lib/wic/engine.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
scripts/lib/wic/engine.py +4 -1
index 83c42c9987..9ff4394757 100644
@@ -291,7 +291,7 @@ class Disk:
 
     def _get_part_image(self, pnum):
         if pnum not in self.partitions:
-            raise WicError("Partition %s is not in the image")
+            raise WicError("Partition %s is not in the image" % pnum)
         part = self.partitions[pnum]
         # check if fstype is supported
         for fstype in self.fstypes:
@@ -314,6 +314,9 @@ class Disk:
                     seek=self.partitions[pnum].start)
 
     def dir(self, pnum, path):
+        if pnum not in self.partitions:
+            raise WicError("Partition %s is not in the image" % pnum)
+
         if self.partitions[pnum].fstype.startswith('ext'):
             return exec_cmd("{} {} -R 'ls -l {}'".format(self.debugfs,
                                                          self._get_part_image(pnum),
Signature · 1 line
2.17.1