Add a hook for reporting exceptions
[lhc/web/wiklou.git] / includes / exception / MWExceptionHandler.php
index 0582b24..a58705f 100644 (file)
@@ -351,7 +351,7 @@ TXT;
         * returns the requested URL. Otherwise, returns false.
         *
         * @since 1.23
-        * @return string|bool
+        * @return string|false
         */
        public static function getURL() {
                global $wgRequest;
@@ -430,7 +430,7 @@ TXT;
         * @param Exception $e
         * @param bool $pretty Add non-significant whitespace to improve readability (default: false).
         * @param int $escaping Bitfield consisting of FormatJson::.*_OK class constants.
-        * @return string|bool JSON string if successful; false upon failure
+        * @return string|false JSON string if successful; false upon failure
         */
        public static function jsonSerializeException( Exception $e, $pretty = false, $escaping = 0 ) {
                global $wgLogExceptionBacktrace;
@@ -486,6 +486,8 @@ TXT;
                        if ( $json !== false ) {
                                wfDebugLog( 'exception-json', $json, 'private' );
                        }
+
+                       Hooks::run( 'LogException', array( $e, false ) );
                }
        }
 
@@ -501,7 +503,8 @@ TXT;
 
                // The set_error_handler callback is independent from error_reporting.
                // Filter out unwanted errors manually (e.g. when wfSuppressWarnings is active).
-               if ( ( error_reporting() & $e->getSeverity() ) !== 0 ) {
+               $suppressed = ( error_reporting() & $e->getSeverity() ) === 0;
+               if ( !$suppressed ) {
                        $log = self::getLogMessage( $e );
                        if ( $wgLogExceptionBacktrace ) {
                                wfDebugLog( $channel, $log . "\n" . $e->getTraceAsString() );
@@ -515,5 +518,7 @@ TXT;
                if ( $json !== false ) {
                        wfDebugLog( "$channel-json", $json, 'private' );
                }
+
+               Hooks::run( 'LogException', array( $e, $suppressed ) );
        }
 }