32 protected static $messageMap = [
33 'actionthrottledtext' =>
'ratelimited',
34 'autoblockedtext' =>
'autoblocked',
35 'badaccess-group0' =>
'permissiondenied',
36 'badaccess-groups' =>
'permissiondenied',
37 'badipaddress' =>
'invalidip',
38 'blankpage' =>
'emptypage',
39 'blockedtext' =>
'blocked',
40 'cannotdelete' =>
'cantdelete',
41 'cannotundelete' =>
'cantundelete',
42 'cantmove-titleprotected' =>
'protectedtitle',
43 'cantrollback' =>
'onlyauthor',
44 'confirmedittext' =>
'confirmemail',
45 'content-not-allowed-here' =>
'contentnotallowedhere',
46 'deleteprotected' =>
'cantedit',
47 'delete-toobig' =>
'bigdelete',
48 'edit-conflict' =>
'editconflict',
49 'imagenocrossnamespace' =>
'nonfilenamespace',
50 'imagetypemismatch' =>
'filetypemismatch',
51 'importbadinterwiki' =>
'badinterwiki',
52 'importcantopen' =>
'cantopenfile',
53 'import-noarticle' =>
'badinterwiki',
54 'importnofile' =>
'nofile',
55 'importuploaderrorpartial' =>
'partialupload',
56 'importuploaderrorsize' =>
'filetoobig',
57 'importuploaderrortemp' =>
'notempdir',
58 'ipb_already_blocked' =>
'alreadyblocked',
59 'ipb_blocked_as_range' =>
'blockedasrange',
60 'ipb_cant_unblock' =>
'cantunblock',
61 'ipb_expiry_invalid' =>
'invalidexpiry',
62 'ip_range_invalid' =>
'invalidrange',
63 'mailnologin' =>
'cantsend',
64 'markedaspatrollederror-noautopatrol' =>
'noautopatrol',
65 'movenologintext' =>
'cantmove-anon',
66 'movenotallowed' =>
'cantmove',
67 'movenotallowedfile' =>
'cantmovefile',
68 'namespaceprotected' =>
'protectednamespace',
69 'nocreate-loggedin' =>
'cantcreate',
70 'nocreatetext' =>
'cantcreate-anon',
71 'noname' =>
'invaliduser',
72 'nosuchusershort' =>
'nosuchuser',
73 'notanarticle' =>
'missingtitle',
74 'nouserspecified' =>
'invaliduser',
75 'ns-specialprotected' =>
'unsupportednamespace',
76 'protect-cantedit' =>
'cantedit',
77 'protectedinterface' =>
'protectednamespace-interface',
78 'protectedpagetext' =>
'protectedpage',
79 'range_block_disabled' =>
'rangedisabled',
80 'rcpatroldisabled' =>
'patroldisabled',
81 'readonlytext' =>
'readonly',
82 'sessionfailure' =>
'badtoken',
83 'systemblockedtext' =>
'blocked',
84 'titleprotected' =>
'protectedtitle',
85 'undo-failure' =>
'undofailure',
86 'userrights-nodatabase' =>
'nosuchdatabase',
87 'userrights-no-interwiki' =>
'nointerwikiuserrights',
94 if ( $this->apiCode ===
null ) {
95 $key = $this->getKey();
96 if ( isset( self::$messageMap[$key] ) ) {
97 $this->apiCode = self::$messageMap[$key];
98 } elseif ( $key ===
'apierror-missingparam' ) {
100 $this->apiCode =
'no' . $this->getParams()[0];
101 } elseif ( substr( $key, 0, 8 ) ===
'apiwarn-' ) {
102 $this->apiCode = substr( $key, 8 );
103 } elseif ( substr( $key, 0, 9 ) ===
'apierror-' ) {
104 $this->apiCode = substr( $key, 9 );
106 $this->apiCode = $key;
114 throw new InvalidArgumentException(
"Invalid code \"$code\"" );
117 $this->apiCode =
$code;
118 if ( $data !==
null ) {
128 $this->apiData = $data;
134 'apiCode' => $this->apiCode,
135 'apiData' => $this->apiData,
142 $this->apiCode = $data[
'apiCode'];
143 $this->apiData = $data[
'apiData'];