From af0f02d19bcdeee698af331a9e1c31df9a327acb Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Tue, 7 May 2019 11:50:57 -0500 Subject: [PATCH] Fix reraising of exceptions Exceptions should be reraised with just "raise" and not "raise e" to preserve the traceback. This also addresses a couple cases where the catching and reraising of the exception was not actually doing anything. Change-Id: I94ba193f728ee7ca6f689f70fc08317a1dd50c92 Signed-off-by: Sean McGinnis --- watcher/applier/actions/base.py | 7 ++----- watcher/applier/actions/volume_migration.py | 7 ++----- watcher/decision_engine/goal/efficacy/indicators.py | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/watcher/applier/actions/base.py b/watcher/applier/actions/base.py index ef1a5c094..6252c1ebc 100644 --- a/watcher/applier/actions/base.py +++ b/watcher/applier/actions/base.py @@ -131,11 +131,8 @@ class BaseAction(loadable.Loadable): raise NotImplementedError() def validate_parameters(self): - try: - jsonschema.validate(self.input_parameters, self.schema) - return True - except jsonschema.ValidationError as e: - raise e + jsonschema.validate(self.input_parameters, self.schema) + return True @abc.abstractmethod def get_description(self): diff --git a/watcher/applier/actions/volume_migration.py b/watcher/applier/actions/volume_migration.py index 6752e7e3c..1319f7f5e 100644 --- a/watcher/applier/actions/volume_migration.py +++ b/watcher/applier/actions/volume_migration.py @@ -109,11 +109,8 @@ class VolumeMigrate(base.BaseAction): } def validate_parameters(self): - try: - jsonschema.validate(self.input_parameters, self.schema) - return True - except jsonschema.ValidationError as e: - raise e + jsonschema.validate(self.input_parameters, self.schema) + return True @property def volume_id(self): diff --git a/watcher/decision_engine/goal/efficacy/indicators.py b/watcher/decision_engine/goal/efficacy/indicators.py index 713291cfa..a5870a825 100644 --- a/watcher/decision_engine/goal/efficacy/indicators.py +++ b/watcher/decision_engine/goal/efficacy/indicators.py @@ -59,7 +59,7 @@ class IndicatorSpecification(object): jsonschema.validate(value, cls.schema) except (SchemaError, ValidationError) as exc: LOG.exception(exc) - raise exc + raise except Exception as exc: LOG.exception(exc) raise exception.InvalidIndicatorValue(