Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve exception with multiples messages #459

Open
LeMyst opened this issue Dec 1, 2022 · 1 comment
Open

Improve exception with multiples messages #459

LeMyst opened this issue Dec 1, 2022 · 1 comment
Assignees

Comments

@LeMyst
Copy link
Owner

LeMyst commented Dec 1, 2022

It seems the exception don't give enough informations in some cases.

For my example, I tried to create a new entity (a property) with already used Labels on the same wikibase instance. Wikibase don't allow this and simply return a "The save have failed" with the default MWApiError:

ERROR:wikibaseintegrator.entities.baseentity:Error while writing to the Wikibase instance
wikibaseintegrator.wbi_exceptions.MWApiError: 'The save has failed.'

but the error returned by WB is really explicit:

{'error': {'*': 'See https://test.wikidata.org/w/api.php for API usage. '
                'Subscribe to the mediawiki-api-announce mailing list at '
                '<https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/> '
                'for notice of API deprecations and breaking changes.',
           'code': 'failed-save',
           'info': 'The save has failed.',
           'messages': [{'html': {'*': 'The save has failed.'},
                         'name': 'wikibase-api-failed-save',
                         'parameters': []},
                        {'html': {'*': 'Property <a '
                                       'href="/wiki/Property:P97083" '
                                       'title="Property:P97083">P97083</a> '
                                       'already has label "Leksem-eksempel for '
                                       'Wikidata-egenskap" associated with '
                                       'language code nb.'},
                         'name': 'wikibase-validator-label-conflict',
                         'parameters': ['Leksem-eksempel for Wikidata-egenskap',
                                        'nb',
                                        '[[Property:P97083|P97083]]']},
                        {'html': {'*': 'Property <a '
                                       'href="/wiki/Property:P97083" '
                                       'title="Property:P97083">P97083</a> '
                                       'already has label "Wikidata property '
                                       'example for lexemes" associated with '
                                       'language code en.'},
                         'name': 'wikibase-validator-label-conflict',
                         'parameters': ['Wikidata property example for lexemes',
                                        'en',
                                        '[[Property:P97083|P97083]]']},
                        {'html': {'*': 'Property <a '
                                       'href="/wiki/Property:P97083" '
                                       'title="Property:P97083">P97083</a> '
                                       'already has label '
                                       '"Wikidata-Eigenschaftsbeispiel für '
                                       'Lexeme" associated with language code '
                                       'de.'},
                         'name': 'wikibase-validator-label-conflict',
                         'parameters': ['Wikidata-Eigenschaftsbeispiel für '
                                        'Lexeme',
                                        'de',
                                        '[[Property:P97083|P97083]]']},
[...]
                        {'html': {'*': 'Property <a '
                                       'href="/wiki/Property:P97083" '
                                       'title="Property:P97083">P97083</a> '
                                       'already has label "詞位類維基數據屬性範例" '
                                       'associated with language code zh-hk.'},
                         'name': 'wikibase-validator-label-conflict',
                         'parameters': ['詞位類維基數據屬性範例',
                                        'zh-hk',
                                        '[[Property:P97083|P97083]]']},
                        {'html': {'*': 'Property <a '
                                       'href="/wiki/Property:P97083" '
                                       'title="Property:P97083">P97083</a> '
                                       'already has label "詞位類維基數據屬性範例" '
                                       'associated with language code zh-tw.'},
                         'name': 'wikibase-validator-label-conflict',
                         'parameters': ['詞位類維基數據屬性範例',
                                        'zh-tw',
                                        '[[Property:P97083|P97083]]']},
                        {'html': {'*': 'Property <a '
                                       'href="/wiki/Property:P97083" '
                                       'title="Property:P97083">P97083</a> '
                                       'already has label "語彙素内での使用例" '
                                       'associated with language code ja.'},
                         'name': 'wikibase-validator-label-conflict',
                         'parameters': ['語彙素内での使用例',
                                        'ja',
                                        '[[Property:P97083|P97083]]']},
                        {'html': {'*': 'Property <a '
                                       'href="/wiki/Property:P97083" '
                                       'title="Property:P97083">P97083</a> '
                                       'already has label "词位类维基数据属性示例" '
                                       'associated with language code '
                                       'zh-hans.'},
                         'name': 'wikibase-validator-label-conflict',
                         'parameters': ['词位类维基数据属性示例',
                                        'zh-hans',
                                        '[[Property:P97083|P97083]]']},
                        {'html': {'*': 'Property <a '
                                       'href="/wiki/Property:P97083" '
                                       'title="Property:P97083">P97083</a> '
                                       'already has label "어휘소를 위한 위키데이터 속성 '
                                       '예시" associated with language code ko.'},
                         'name': 'wikibase-validator-label-conflict',
                         'parameters': ['어휘소를 위한 위키데이터 속성 예시',
                                        'ko',
                                        '[[Property:P97083|P97083]]']}]},
 'servedby': 'mw1377'}

WBI exceptions must be improved to give more informations.

@WolfgangFahl
Copy link

Another example:

   raise ModificationFailed(json_data['error'])
wikibaseintegrator.wbi_exceptions.ModificationFailed: 'Item [[Q116472444|Q116472444]] already has label "Xiao Liu" associated with language code en, using the same description text.'

see

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants