More elegant error handling

This commit is contained in:
2022-06-20 11:27:05 +01:00
parent 90bc30757a
commit 49a7fb1007
3 changed files with 18 additions and 23 deletions

View File

@ -1,6 +1,7 @@
from ..extensions import db
from flask import jsonify
from wtforms.validators import ValidationError
import json
@ -53,4 +54,8 @@ def get_dataset_choices():
label = f'{label} (Default)' if dataset.default else label
choice = (dataset.id, label)
dataset_choices.append(choice)
return dataset_choices
return dataset_choices
def send_errors_to_client(form):
errors = [*form.errors]
return jsonify({ 'error': errors}), 400