[elbe-devel] [PATCH 4/6] Fix issues with exceptions handling.

dion at linutronix.de dion at linutronix.de
Thu Jul 18 14:02:44 CEST 2019


From: Olivier Dion <dion at linutronix.de>

KeyError exception was too general and could have been throw either by
the FinetuningAction constructor or by any other 'execute/excute_prj'
methods.

Also, e.message was a nasty error that could crash the daemon since
not supported by python anymore.

Signed-off-by: Olivier Dion <dion at linutronix.de>
---
 elbepack/finetuning.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/elbepack/finetuning.py b/elbepack/finetuning.py
index 375f2e99..ec1fde9d 100644
--- a/elbepack/finetuning.py
+++ b/elbepack/finetuning.py
@@ -44,6 +44,8 @@ class FinetuningAction(object):
         return _register
 
     def __new__(cls, node):
+        if node.tag not in cls.actiondict:
+            raise FinetuningException("Invalid finetuning action %s" % node.tag)
         action = cls.actiondict[node.tag]
         return object.__new__(action)
 
@@ -720,10 +722,11 @@ def do_prj_finetuning(xml, log, buildenv, target, builddir):
         try:
             action = FinetuningAction(i)
             action.execute_prj(log, buildenv, target, builddir)
-        except KeyError:
-            print("Unimplemented project-finetuning action '%s'" % (i.et.tag))
         except CommandError:
             log.printo("ProjectFinetuning Error, trying to continue anyways")
         except FinetuningException as e:
-            log.printo("ProjectFinetuning Error: %s" % e.message)
+            log.printo("ProjectFinetuning Error: %s" % e)
             log.printo("trying to continue anyways")
+        except Exception as e:
+            log.printo(str(e))
+            raise
-- 
2.11.0




More information about the elbe-devel mailing list