Page MenuHomePhabricator

Throw specific error instead of generic APIError if claim target is deleted
Closed, InvalidPublic

Description

Author: felix

Description:
If adding a claim, two types of errors are thrown in case of a deleted item:

item = pywikibot.ItemPage(repo, "Q726")
target = pywikibot.ItemPage(repo, "Q14854094")
c = pywikibot.Claim(repo, u'P171')
c.addTarget(target)
item.addClaim(c) # Error if item or target were deleted

At the last line, you get either

pywikibot.exceptions.NoPage: Page [[wikidata:-1]] doesn't exist.

if item (Q726) has been deleted or

pywikibot.data.api.APIError: invalid-snak-value: Q14854094 not found

if the target (Q14854094) has been deleted.

It would be great, if for the latter a specific "InvalidValueError" or similar would be thrown. Then, the error could be caught and handled specifically without the need to parse the (possibly changing) API error message itself.


Version: core-(2.0)
Severity: minor

Details

Reference
bz62261

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 3:00 AM
bzimport set Reference to bz62261.

I think we have solved the first part of the problem: pywikibot.exceptions.NoPage: Page [[wikidata:-1]] doesn't exist. It should now give a useful NoPage error message.

But I am pretty sure that the second part of the problem isnt solved: pywikibot.data.api.APIError: invalid-snak-value: Q14854094 not found
TestMe

@jayvdb Are you still working on this task?

Probably not as @jayvdb stepped away from Pywikibot development (see T179775#4141290)

Xqt removed jayvdb as the assignee of this task.Nov 24 2018, 2:14 PM
Xqt subscribed.

Could not verify this task. The api has been changed in meantime and a lot of improvements were made in the last 8 years. Please reopen, if you have reproducable steps with current release.