API:Errors and warnings/ja

If something goes wrong in an API request, an error or a warning will be thrown (although the HTTP response will usually still be ). Warnings are thrown for non-fatal conditions such as invalid parameters, whereas errors are only thrown for fatal conditions.

Warnings
Warnings are grouped by the name of the module that caused them. Multiple warnings from the same module are separated by a newline. In the legacy error formatting mode (see below), which is the default, warnings are output in the following format:

( will be replaced by   when   is used.)

When a non-legacy error formatting option is used, warnings are output in the same format as errors. E.g. with the format will be: ( will be replaced with   when    is used.)

Error formats
Since MediaWiki 1.29 errors are localizable, and available in multiple formats. An error (or warning) is expected to consist of a message, an error code (an arbitrary string, usually generated from the message key; see also below), and optional extra data (an associative array). An API response with errors will look like this:

The  key in the output above will be missing if there is no extra data to display.

The way the error message in the output above is returned to the client is controlled by the  API parameter. The various error formats available are:

For the formatting modes which involve message lookup (,  and  ) the API parameter   can be used to set the language (only needed when different from the content language) and   to set whether the MediaWiki: namespace can be used to override default error messages.

Error codes are also returned in the  response HTTP header, separated by commas when there are multiple errors.

For an example error response or to test your client's error handling, visit https://en.wikipedia.org/w/api.php?action=blah&errorformat=plaintext&format=jsonfm&formatversion=2

When  is not set (or set to  ), errors will be displayed in the legacy format instead.

Legacy format
In the legacy error format, there is always at most one error; additional ones are discarded. The response looks like this:

The extra data in the output above is spliced into the object instead of being under the  key.

Error messages in documentation
Error messages are documented in this wiki as shown below, which corresponds to the json error response in above:

The various error messages are:

Standard error messages
Some generic error messages are shared among modules. If a module can throw these errors, that's explicitly mentioned in its  section.

Additional notes

 * All error and warning outputs above use . For , the field   will be replaced by.