Commit 8034f2fb authored by Pierre Dittgen's avatar Pierre Dittgen

Better format error handling

parent 756be367
......@@ -54,43 +54,6 @@ def extract_source_data(source: ValidataSource, preview_rows_nb=5):
'preview_rows': rows[:preview_rows_nb]}
# ERR_CODE_TO_CONTEXT = dict([
# # TODO: gets it from spec.json
# ('duplicate-header', 'head'),
# ('extra-value', 'body'),
# ('missing-value', 'body'),
# ('source-error', 'table'),
# ('schema-error', 'table'),
# ('non-matching-header', 'head'),
# ('blank-row', 'body'),
# ('blank-header', 'head'),
# ('enumerable-constraint', 'body'),
# ('http-error', 'table'),
# ('scheme-error', 'table'),
# ('type-or-format-error', 'body'),
# ('format-error', 'table'),
# ('extra-header', 'head'),
# ('pattern-constraint', 'body'),
# ('required-constraint', 'body'),
# ('missing-header', 'head'),
# ('maximum-length-constraint', 'body'),
# ('maximum-constraint', 'body'),
# ('minimum-length-constraint', 'body'),
# ('encoding-error', 'table'),
# ('io-error', 'table'),
# ('unique-constraint', 'body'),
# ('duplicate-row', 'body'),
# ('minimum-constraint', 'body'),
# # TODO: get it from validata_validate
# ('invalid-column-delimiter', 'table'),
# ('missing-headers', 'table'),
# ('wrong-headers-order', 'table'),
# ('extra-headers', 'table'),
# # Custom checks fall in default case: body
# ])
ERROR_MESSAGE_FUNC = {
# Core checks
......@@ -220,7 +183,11 @@ def create_validata_report(goodtables_report, schema):
def validate(schema_code, source: ValidataSource):
""" Validate source and display report """
goodtables_report = ValidatorHelper.validate(schema_code, **source.get_goodtables_source())
try:
goodtables_report = ValidatorHelper.validate(schema_code, **source.get_goodtables_source())
except tabulator.exceptions.FormatError:
flash_error('Erreur : format de fichier non supporté')
return redirect(url_for('scdl_validator', val_code=schema_code))
source_data = extract_source_data(source)
......@@ -299,7 +266,7 @@ def scdl_validator(val_code):
else: # POST
input_param = request.form.get('input')
if input_param is None:
flash_error('Source non définie')
flash_error('Aucun fichier à valider')
return redirect(url_for('scdl_validator', val_code=val_code))
# File validation
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment