diff options
author | Thomas Herve <thomas.herve@enovance.com> | 2014-02-05 15:38:50 +0100 |
---|---|---|
committer | Thomas Herve <thomas.herve@enovance.com> | 2014-03-26 09:57:45 +0100 |
commit | 573a15a7e1042f6f131d227ac8971fe8795d8c00 (patch) | |
tree | bcea9c24a7a979add6dd0ad4acc3e1618c502b98 /heat/engine/constraints.py | |
parent | f18bb8b5af080d8f1114815bc2aac0ec2433146e (diff) | |
download | heat-573a15a7e1042f6f131d227ac8971fe8795d8c00.tar.gz |
Raise and catch a specific error during validation
This changes stack creation to return an error message instead of an
exception when (some) validation fails. It doesn't convert all validation
errors to keep the patch at a reasonable size.
Change-Id: I6364bccacbc1d447a99ea61565c96fcc90bd21f9
Partial-Bug: #1276623
Diffstat (limited to 'heat/engine/constraints.py')
-rw-r--r-- | heat/engine/constraints.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/heat/engine/constraints.py b/heat/engine/constraints.py index 61b9c055d..3378df732 100644 --- a/heat/engine/constraints.py +++ b/heat/engine/constraints.py @@ -18,6 +18,8 @@ import re from heat.engine import resources +from heat.common import exception + class InvalidSchemaError(Exception): pass @@ -144,8 +146,11 @@ class Schema(collections.Mapping): return float(value) def validate_constraints(self, value, context=None): - for constraint in self.constraints: - constraint.validate(value, context) + try: + for constraint in self.constraints: + constraint.validate(value, context) + except ValueError as ex: + raise exception.StackValidationFailed(message=str(ex)) def __getitem__(self, key): if key == self.TYPE: |