Skip to content
Snippets Groups Projects
Commit f2e21988 authored by florian's avatar florian
Browse files

API: Use BadQueryErrors in datatype.py

parent cbbc561e
No related branches found
No related tags found
No related merge requests found
......@@ -25,8 +25,7 @@
import re
from ..exceptions import (AmbiguityException, EntityDoesNotExistError,
TransactionError)
from ..exceptions import EmptyUniqueQueryError, QueryNotUniqueError
DOUBLE = "DOUBLE"
REFERENCE = "REFERENCE"
......@@ -92,9 +91,9 @@ def get_id_of_datatype(datatype):
Raises
------
AmbiguityException
QueryNotUniqueError
If there are more than one entities with the same name as the datatype.
EntityDoesNotExistError
EmptyUniqueQueryError
If there is no entity with the name of the datatype.
"""
from caosdb import execute_query
......@@ -108,12 +107,11 @@ def get_id_of_datatype(datatype):
res = [el for el in res if el.name.lower() == datatype.lower()]
if len(res) > 1:
raise AmbiguityException(
raise QueryNotUniqueError(
"Name {} did not lead to unique result; Missing "
"implementation".format(datatype))
elif len(res) != 1:
ee = EntityDoesNotExistError(
raise EmptyUniqueQueryError(
"No RecordType named {}".format(datatype))
raise TransactionError(ee)
return res[0].id
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