From ff0fb3892b1bc9c1db925c316af60637dfeb24f5 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 22 Jan 2014 12:12:15 +0200 Subject: [PATCH] BmapCreate: catch exception from the Filemap module 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 --- bmaptools/BmapCreate.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bmaptools/BmapCreate.py b/bmaptools/BmapCreate.py index 3df1446..7275cd5 100644 --- a/bmaptools/BmapCreate.py +++ b/bmaptools/BmapCreate.py @@ -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) -- 2.7.4