[Fix] Catch Exception for Adding Structures / Show PubChem Substances (#168)

Fixes #163
Fixes #165

Co-authored-by: Tim Lorsbach <tim@lorsba.ch>
Reviewed-on: enviPath/enviPy#168
This commit is contained in:
2025-10-22 01:13:06 +13:00
parent 376fd65785
commit 819a94aced
3 changed files with 36 additions and 8 deletions

View File

@ -1251,7 +1251,16 @@ def package_compound_structures(request, package_uuid, compound_uuid):
structure_smiles = request.POST.get("structure-smiles")
structure_description = request.POST.get("structure-description")
cs = current_compound.add_structure(structure_smiles, structure_name, structure_description)
try:
cs = current_compound.add_structure(
structure_smiles, structure_name, structure_description
)
except ValueError:
return error(
request,
"Adding structure failed!",
"The structure could not be added as normalized structures don't match!",
)
return redirect(cs.url)