On 2020-02-22 10:59, Chen Xinyan wrote:
Just out of curiosity, is there any recommended way to
parse out "which" parameter goes wrong. For example, we have
"unknown_action" before. Now it gets merged into "badvalue", and the
response looks like this:
...
Do I have to parse into .error.info content to know the parameter name?
You can use the 'errorformat=raw' parameter to get the internal data
used to construct the error message. It's mostly machine-readable, but I
don't think it comes with any documentation or compatibility guarantees,
the format could change at any time in new MW releases.
https://test2.wikipedia.org/w/api.php?action=test&errorformat=raw
For a long-term solution, I'd recommend filing a task to make the API
return this data in another way.
Would its content change (such as localized) under
certain situation?
In the default format ('errorformat=bc') the error message is never
localized, but it can change in new MW releases without warning.
(If you wanted a localized message,
'errorformat=html'/'plaintext'/'wikitext' provides that, with the
language specified by 'errorlang'.)
--
Bartosz Dziewoński