Merge pull request #174 from bukzor/buck-172-error-clobbering

fix error clobbering
This commit is contained in:
Anthony Sottile 2014-10-01 16:17:10 -07:00
commit 7119acdc7d
2 changed files with 8 additions and 5 deletions

View file

@ -21,9 +21,9 @@ def is_regex_valid(regex):
def get_validator( def get_validator(
json_schema, json_schema,
exception_type, exception_type,
additional_validation_strategy=lambda obj: None, additional_validation_strategy=lambda obj: None,
): ):
"""Returns a function which will validate a yaml file for correctness """Returns a function which will validate a yaml file for correctness
@ -44,14 +44,14 @@ def get_validator(
obj = load_strategy(file_contents) obj = load_strategy(file_contents)
except Exception as e: except Exception as e:
raise exception_type( raise exception_type(
'File {0} is not a valid yaml file'.format(filename), e, 'Invalid yaml: {0}\n{1}'.format(os.path.relpath(filename), e),
) )
try: try:
jsonschema.validate(obj, json_schema) jsonschema.validate(obj, json_schema)
except jsonschema.exceptions.ValidationError as e: except jsonschema.exceptions.ValidationError as e:
raise exception_type( raise exception_type(
'File {0} is not a valid file'.format(filename), e, 'Invalid content: {0}\n{1}'.format(os.path.relpath(filename), e),
) )
obj = apply_defaults(obj, json_schema) obj = apply_defaults(obj, json_schema)

View file

@ -23,3 +23,6 @@ deps =
sphinx sphinx
changedir = docs changedir = docs
commands = sphinx-build -b html -d build/doctrees source build/html commands = sphinx-build -b html -d build/doctrees source build/html
[flake8]
max-line-length=131