diff --git a/CHANGELOG.md b/CHANGELOG.md index 92324b78338948cf1a4f68bb41afeaa2894b4987..fc71f20dd6c9d4e232fb18a951f27f8bafedd21f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Dynamic exception type `EntityMultiError`. * `get_something` functions from all error object in `exceptions.py` +* `AmbiguityException` ### Fixed ### diff --git a/src/caosdb/common/models.py b/src/caosdb/common/models.py index 7760166f97233ded0431164ccef0492c223e2f80..467e0e71072912bfbb6b7e07da3980e17cec4d60 100644 --- a/src/caosdb/common/models.py +++ b/src/caosdb/common/models.py @@ -48,7 +48,7 @@ from caosdb.common.utils import uuid, xml2str from caosdb.configuration import get_config from caosdb.connection.connection import get_connection from caosdb.connection.encode import MultipartParam, multipart_encode -from caosdb.exceptions import (AmbiguityError, +from caosdb.exceptions import (AmbiguousEntityError, AuthorizationError, CaosDBException, CaosDBConnectionError, ConsistencyError, @@ -995,11 +995,18 @@ class Entity(object): if self.id is None: c = Container().retrieve(query=self.name, sync=False) - if len(c == 1): + if len(c) == 1: e = c[0] + elif len(c) == 0: + raise EntityDoesNotExistError( + "The entity to be updated does not exist on the server.", + entity=self + ) else: - raise AmbiguityError( - "Could not determine the desired Entity which is to be updated by its name.") + raise AmbiguousEntityError( + "Could not determine the desired Entity which is to be updated by its name.", + entity=self + ) else: e = Container().retrieve(query=self.id, sync=False)[0] e.acl = ACL(self.acl.to_xml()) diff --git a/src/caosdb/exceptions.py b/src/caosdb/exceptions.py index 9217febf86d0138673ae2ff54a0e4156d93b7198..01c3437bc3f28b107c2e5f0a8a69a66d56e81bcc 100644 --- a/src/caosdb/exceptions.py +++ b/src/caosdb/exceptions.py @@ -103,14 +103,6 @@ class URITooLongError(HTTPClientError): HTTPClientError.__init__(self, msg=msg, status=414, body=None) -class AmbiguityError(CaosDBException): - """A retrieval of an entity that was supposed to be uniquely identifiable - returned two or more entities.""" - - def __init__(self, msg=None): - CaosDBException.__init__(self, msg) - - class LoginFailedError(CaosDBException): """Login failed.