Commit ce6ccb1b authored by Pierre Dittgen's avatar Pierre Dittgen
Browse files

Better error display on source error

parent ae4b0349
...@@ -8,7 +8,6 @@ import json ...@@ -8,7 +8,6 @@ import json
import logging import logging
import subprocess import subprocess
import tempfile import tempfile
import time
from datetime import datetime from datetime import datetime
from io import BytesIO from io import BytesIO
from operator import itemgetter from operator import itemgetter
...@@ -220,6 +219,15 @@ def validate(schema_code, source: ValidataSource): ...@@ -220,6 +219,15 @@ def validate(schema_code, source: ValidataSource):
flash_error('Erreur : format de fichier non supporté') flash_error('Erreur : format de fichier non supporté')
return redirect(url_for('scdl_validator', val_code=schema_code)) return redirect(url_for('scdl_validator', val_code=schema_code))
# source_errors = [err for err in validata_core_report['tables'][0]['errors'] if err['code'] == 'source-error']
source_errors = [err for err in validata_core_report['tables'][0]['errors'] if err['code'] == 'source-error']
if source_errors:
err = source_errors[0]
msg = "l'encodage du fichier est invalide. Veuillez le corriger" if 'charmap' in err[
'message'] else err['message']
flash_error('Erreur de source : {}'.format(msg))
return redirect(url_for('scdl_validator', val_code=schema_code))
source_data = extract_source_data(source) source_data = extract_source_data(source)
# handle report date # handle report date
......
Supports Markdown
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