Include log id in api error response
authorumherirrender <umherirrender_de.wp@web.de>
Sat, 27 Dec 2014 21:16:29 +0000 (22:16 +0100)
committerUmherirrender <umherirrender_de.wp@web.de>
Sat, 27 Dec 2014 21:34:37 +0000 (21:34 +0000)
For internal api error it is helpful for reporting when having the log
id under the exception was logged in the exception log.

Also use the redacted trace in the api error response instead of the
normal one to avoid leakage of function values if exception details are shown.

Change-Id: I7d917e532da1b1c7979a6599425f07d2f4f35aed

includes/api/ApiMain.php

index a5287b6..99f90ee 100644 (file)
@@ -710,11 +710,13 @@ class ApiMain extends ApiBase {
 
                        $errMessage = array(
                                'code' => 'internal_api_error_' . get_class( $e ),
-                               'info' => $info,
+                               'info' => '[' . MWExceptionHandler::getLogId( $e ) . '] ' . $info,
                        );
                        ApiResult::setContent(
                                $errMessage,
-                               $config->get( 'ShowExceptionDetails' ) ? "\n\n{$e->getTraceAsString()}\n\n" : ''
+                               $config->get( 'ShowExceptionDetails' )
+                                       ? "\n\n" . MWExceptionHandler::getRedactedTraceAsString( $e ) . "\n\n"
+                                       : ''
                        );
                }