Page MenuHomePhabricator

Throw specific error instead of generic APIError if claim target is deleted
Open, HighPublic

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 added a project: Pywikibot-Wikidata.
bzimport set Reference to bz62261.
bzimport created this task.Mar 5 2014, 4:34 PM
jayvdb updated the task description. (Show Details)Feb 19 2015, 7:20 PM
jayvdb set Security to None.

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

Restricted Application added a subscriber: TerraCodes. · View Herald TranscriptSep 25 2016, 4:57 AM

@jayvdb Are you still working on this task?

@jayvdb Are you still working on this task?

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

D3r1ck01 moved this task from Backlog to Needs Review on the Pywikibot board.Nov 5 2018, 11:39 AM
Xqt removed jayvdb as the assignee of this task.Nov 24 2018, 2:14 PM