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

Torben Hohn torben.hohn at linutronix.de
Wed Aug 7 11:07:34 CEST 2019


On Thu, Jul 18, 2019 at 02:02:44PM +0200, dion at linutronix.de wrote:
> 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>

Reviewed-by: Torben Hohn <torben.hohn 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
> 
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner



More information about the elbe-devel mailing list