LeMyst / LeMyst/WikibaseIntegrator

Improve exception with multiples messages

Closed
#459 1 comment 1 reaction 1 assignee View on GitHub

@LeMyst is already working on this.

Since Dec 1, 2022.

Dominant language
Python
Stars
92
Forks
22
Avg merge
2d 34m
Merged PRs (30d)
10

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.