Manual:Hooks/ApiMain::onException

From MediaWiki.org
Jump to navigation Jump to search
ApiMain::onException
Available from version 1.20.0
Called by ApiMain::executeActionWithErrorHandling() when an exception is thrown during API action execution.
Define function:
public static function onApiMain_onException( ApiMain $apiMain, Exception $e ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"ApiMain::onException": "MyExtensionHooks::onApiMainonException"
	}
}

For MediaWiki ≤1.25:

$wgHooks['ApiMain::onException'][] = 'MyExtensionHooks::onApiMainonException';
Called from:File(s): api/ApiMain.php

For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:ApiMain::onException extensions.

Details[edit]

Called by ApiMain::executeActionWithErrorHandling() when an exception is thrown during API action execution.

  • $apiMain: Calling ApiMain instance.
  • $e: Exception object.