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

ENH: Add original query to unique query error messages

parent af6cdb84
Branches
Tags
No related merge requests found
......@@ -49,7 +49,7 @@ from caosdb.connection.encode import MultipartParam, multipart_encode
from caosdb.exceptions import (AmbiguityException,
AuthorizationException,
CaosDBException, ConnectionException,
ConsistencyError, ContainerError,
ConsistencyError,
EntityDoesNotExistError, EntityError,
EntityHasNoDatatypeError,
TransactionError, UniqueNamesError,
......@@ -3480,9 +3480,11 @@ class Query():
if unique:
if len(cresp) > 1 and raise_exception_on_error:
raise AmbiguityException("This query wasn't unique")
raise AmbiguityException("Query '{}' wasn't unique.".format(q))
elif len(cresp) == 0 and raise_exception_on_error:
raise EntityDoesNotExistError("No such entity found.")
ee = EntityDoesNotExistError(
"Query '{}' found no results.".format(q))
raise TransactionError(ee)
elif len(cresp) == 1:
r = cresp[0]
r.messages.extend(cresp.messages)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment