BmapCreate: catch exception from the Filemap module
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Wed, 22 Jan 2014 10:12:15 +0000 (12:12 +0200)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Wed, 22 Jan 2014 10:12:15 +0000 (12:12 +0200)
The 'Filemap' module can raise exceptions in case of errors. Let's catch them
and re-raise as 'BmapCreate.Error' exceptions. This will make 'bmaptool' catch
them too and print a nice error message.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
bmaptools/BmapCreate.py

index 3df14461b4368948f7c9a5235883332b29ec3a55..7275cd56b8c742e736d2b78e07ce44010843704d 100644 (file)
@@ -171,7 +171,11 @@ class BmapCreate(object):
             self._bmap_path = bmap
             self._open_bmap_file()
 
-        self.filemap = Filemap.filemap(self._f_image, self._log)
+        try:
+            self.filemap = Filemap.filemap(self._f_image, self._log)
+        except (Filemap.Error, Filemap.ErrorNotSupp) as err:
+            raise Error("cannot generate bmap for file '%s': %s"
+                        % (self._image_path, err))
 
         self.image_size = self.filemap.image_size
         self.image_size_human = human_size(self.image_size)