Skip to content
Snippets Groups Projects
Verified Commit d9fed9b2 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

ENH: Better error messages.

parent 2423efd7
No related branches found
No related tags found
2 merge requests!100WIP: Filling XLSX: Seems to be working.,!93Filling XLSX: Everything except multiple choice.
Pipeline #48402 passed
......@@ -204,11 +204,15 @@ class TableTemplateGenerator(ABC):
# and add the foreign keys that are necessary up to this point
for array_path in array_paths:
foreigns = self._get_foreign_keys(foreign_keys, array_path)
if isinstance(foreigns, str):
raise ValueError("Foreign keys must be a list of strings, but a single "
"string was given:\n"
f"{array_path} -> {foreigns}")
for foreign in foreigns:
internal_key = p2s(array_path + [foreign])
if internal_key in sheets[sheetname]:
raise ValueError("The schema would lead to two columns with the same "
f"name, which is forbidden: {internal_key}")
f"name, which is forbidden:\n{foreign} -> {internal_key}")
ref_sheet = p2s(array_path)
sheets[sheetname][internal_key] = (
ColumnType.FOREIGN, f"see sheet '{ref_sheet}'", array_path + [foreign])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment