From: Max Semenik Date: Fri, 24 Aug 2012 23:57:54 +0000 (+0400) Subject: New hook ApiMain::onException X-Git-Tag: 1.31.0-rc.0~22549^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%20%22id_auteur=%24id%22%29%20.%20%22?a=commitdiff_plain;h=a1cedee3c4a45fcecdae9e2d06b13f92404d7f6a;p=lhc%2Fweb%2Fwiklou.git New hook ApiMain::onException Allows custom logging of API errors Change-Id: If8841c33998dff96448a7eb8dbe95d68119e068f --- diff --git a/docs/hooks.txt b/docs/hooks.txt index ca4657823e..7844aaf48c 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -397,6 +397,11 @@ is the User object. In the hook, just add your callback to the $tokenFunctions array and return true (returning false makes no sense) $tokenFunctions: array(action => callback) +'ApiMain::onException': Called by ApiMain::executeActionWithErrorHandling() +when an exception is thrown during API action execution. +$apiMain: Calling ApiMain instance. +$e: Exception object. + 'ApiRsdServiceApis': Add or remove APIs from the RSD services list. Each service should have its own entry in the $apis array and have a unique name, passed as key for the array that represents the service data. diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 420acd3d9e..2a94a65f4f 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -368,6 +368,9 @@ class ApiMain extends ApiBase { try { $this->executeAction(); } catch ( Exception $e ) { + // Allow extra cleanup and logging + wfRunHooks( 'ApiMain::onException', array( $this, $e ) ); + // Log it if ( !( $e instanceof UsageException ) ) { wfDebugLog( 'exception', $e->getLogMessage() );