A self-format exception, ClaimNotPermitted.
Change-Id: I8bc8f8d8f9f74f3e7400f00fbfcc72d2cdb945cd
This commit is contained in:
@@ -46,3 +46,11 @@ class ClaimDoesNotExist(DoesNotExist):
|
||||
"queue %(queue)s of tenant %(tenant)s") %
|
||||
dict(cid=cid, queue=queue, tenant=tenant))
|
||||
super(ClaimDoesNotExist, self).__init__(msg)
|
||||
|
||||
|
||||
class ClaimNotPermitted(NotPermitted):
|
||||
|
||||
def __init__(self, mid, cid):
|
||||
msg = (_("Message %(mid)s is not claimed by %(cid)s") %
|
||||
dict(cid=cid, mid=mid))
|
||||
super(ClaimNotPermitted, self).__init__(msg)
|
||||
|
||||
@@ -251,15 +251,10 @@ class Message(base.MessageBase):
|
||||
''', id, _cid_decode(claim))
|
||||
|
||||
if not self.driver.affected:
|
||||
raise _BadID
|
||||
raise exceptions.ClaimNotPermitted(_msgid_encode(id), claim)
|
||||
|
||||
except _BadID:
|
||||
#TODO(zyuan): use exception itself to format this
|
||||
msg = (_("Attempt to delete message %(id)s "
|
||||
"with a wrong claim")
|
||||
% dict(id=_msgid_encode(id)))
|
||||
|
||||
raise exceptions.NotPermitted(msg)
|
||||
raise exceptions.ClaimNotPermitted(_msgid_encode(id), claim)
|
||||
|
||||
|
||||
class Claim(base.ClaimBase):
|
||||
|
||||
Reference in New Issue
Block a user