From 42a95b7a93e814b159907372ee108e4da0da6aa4 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sat, 27 Dec 2014 22:16:29 +0100 Subject: [PATCH] Include log id in api error response 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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index a5287b6a10..99f90eea6e 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -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" + : '' ); } -- 2.20.1