|
15 | 15 | cleanup_global_controls
|
16 | 16 | from chaoslib.deprecation import warn_about_deprecated_features
|
17 | 17 | from chaoslib.exceptions import ActivityFailed, ChaosException, \
|
18 |
| - InterruptExecution, InvalidActivity, InvalidExperiment |
| 18 | + InterruptExecution, InvalidActivity, InvalidExperiment, ValidationError |
19 | 19 | from chaoslib.extension import validate_extensions
|
20 | 20 | from chaoslib.configuration import load_configuration
|
21 | 21 | from chaoslib.hypothesis import ensure_hypothesis_is_valid, \
|
@@ -55,10 +55,14 @@ def ensure_experiment_is_valid(experiment: Experiment):
|
55 | 55 | """
|
56 | 56 | logger.info("Validating the experiment's syntax")
|
57 | 57 |
|
| 58 | + full_validation_msg = 'Experiment is not valid, ' \ |
| 59 | + 'please fix the following errors' |
58 | 60 | errors = []
|
59 | 61 |
|
60 | 62 | if not experiment:
|
61 |
| - raise InvalidExperiment("an empty experiment is not an experiment") |
| 63 | + # empty experiment, cannot continue validation any further |
| 64 | + raise ValidationError(full_validation_msg, |
| 65 | + "an empty experiment is not an experiment") |
62 | 66 |
|
63 | 67 | if not experiment.get("title"):
|
64 | 68 | errors.append(InvalidExperiment("experiment requires a title"))
|
@@ -103,11 +107,7 @@ def ensure_experiment_is_valid(experiment: Experiment):
|
103 | 107 | errors.extend(validate_controls(experiment))
|
104 | 108 |
|
105 | 109 | if errors:
|
106 |
| - full_validation_msg = 'Experiment is not valid, ' \ |
107 |
| - 'please fix the following errors:' |
108 |
| - for error in errors: |
109 |
| - full_validation_msg += '\n- {}'.format(error) |
110 |
| - raise InvalidExperiment(full_validation_msg) |
| 110 | + raise ValidationError(full_validation_msg, errors) |
111 | 111 |
|
112 | 112 | logger.info("Experiment looks valid")
|
113 | 113 |
|
|
0 commit comments