Skip to content

Commit 4d88def

Browse files
committed
Fix misleading error message
1 parent 7575d59 commit 4d88def

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

gmn/src/d1_gmn/app/did.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ def is_valid_pid_for_create(did):
5959
)
6060

6161

62+
def is_valid_sid_for_new_standalone(did):
63+
"""Return True if {did} can be assigned to a new standalone object
64+
"""
65+
return _is_unused_did(did)
66+
67+
6268
def is_valid_pid_to_be_updated(did):
6369
"""Return True if {did} is the PID of an object that can be updated
6470
(obsoleted) with MNStorage.update()
@@ -69,12 +75,6 @@ def is_valid_pid_to_be_updated(did):
6975
)
7076

7177

72-
def is_valid_sid_for_new_standalone(did):
73-
"""Return True if {did} can be assigned to a new standalone object
74-
"""
75-
return _is_unused_did(did)
76-
77-
7878
def is_valid_sid_for_chain(pid, sid):
7979
"""Return True if {sid} can be assigned to the single object {pid} or to the
8080
chain to which {pid} belongs.
@@ -148,6 +148,12 @@ def classify_identifier(did):
148148
return 'a Series ID (SID) of a revision chain'
149149
elif is_local_replica(did):
150150
return 'a Persistent ID (PID) of a local replica'
151+
elif is_unprocessed_local_replica(did):
152+
return 'a Persistent ID (PID) of an accepted but not yet processed local replica'
153+
elif is_archived(did):
154+
return 'a Persistent ID (PID) of a previously archived local object'
155+
elif is_obsoleted(did):
156+
return 'a Persistent ID (PID) of a previously updated (obsoleted) local object'
151157
elif is_resource_map_db(did):
152158
return 'a Persistent ID (PID) of a local resource map'
153159
elif is_existing_object(did):

gmn/src/d1_gmn/app/views/assert_db.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,14 @@ def is_valid_pid_for_create(did):
7878

7979

8080
def is_valid_pid_to_be_updated(did):
81+
"""Assert that {did} is the PID of an object that can be updated (obsoleted)
82+
with MNStorage.update()
83+
"""
8184
if not d1_gmn.app.did.is_valid_pid_to_be_updated(did):
8285
raise d1_common.types.exceptions.InvalidRequest(
83-
0,
84-
'Identifier cannot be used for an update. did="{}" cause="Object is {}"'
85-
.format(did, d1_gmn.app.did.classify_identifier(did)), identifier=did
86+
0, 'Object cannot be updated because the identifier for the object to be '
87+
'updated is {}. did="{}"'.format(
88+
d1_gmn.app.did.classify_identifier(did), did), identifier=did
8689
)
8790

8891

0 commit comments

Comments
 (0)