Remove a couple of duplicated errors from ApiEditPage getPossibleErrors

Unindent one level in ApiMain substituteResultWithError
This commit is contained in:
Sam Reed 2010-02-15 23:56:09 +00:00
parent 81a51365ec
commit 7478ad3576
2 changed files with 40 additions and 42 deletions

View file

@ -350,11 +350,9 @@ class ApiEditPage extends ApiBase {
array( 'nosuchrevid', 'undo' ),
array( 'nosuchrevid', 'undoafter' ),
array( 'revwrongpage', 'id', 'text' ),
array( 'revwrongpage', 'id', 'text' ),
array( 'undo-failure' ),
array( 'hashcheckfailed' ),
array( 'hookaborted' ),
array( 'hookaborted' ),
array( 'noimageredirect-anon' ),
array( 'noimageredirect-logged' ),
array( 'spamdetected', 'spam' ),

View file

@ -339,53 +339,53 @@ class ApiMain extends ApiBase {
*/
protected function substituteResultWithError( $e ) {
// Printer may not be initialized if the extractRequestParams() fails for the main module
if ( !isset ( $this->mPrinter ) ) {
// The printer has not been created yet. Try to manually get formatter value.
$value = $this->getRequest()->getVal( 'format', self::API_DEFAULT_FORMAT );
if ( !in_array( $value, $this->mFormatNames ) )
$value = self::API_DEFAULT_FORMAT;
// Printer may not be initialized if the extractRequestParams() fails for the main module
if ( !isset ( $this->mPrinter ) ) {
// The printer has not been created yet. Try to manually get formatter value.
$value = $this->getRequest()->getVal( 'format', self::API_DEFAULT_FORMAT );
if ( !in_array( $value, $this->mFormatNames ) )
$value = self::API_DEFAULT_FORMAT;
$this->mPrinter = $this->createPrinterByName( $value );
if ( $this->mPrinter->getNeedsRawData() )
$this->getResult()->setRawMode();
}
$this->mPrinter = $this->createPrinterByName( $value );
if ( $this->mPrinter->getNeedsRawData() )
$this->getResult()->setRawMode();
}
if ( $e instanceof UsageException ) {
//
// User entered incorrect parameters - print usage screen
//
$errMessage = $e->getMessageArray();
if ( $e instanceof UsageException ) {
//
// User entered incorrect parameters - print usage screen
//
$errMessage = $e->getMessageArray();
// Only print the help message when this is for the developer, not runtime
if ( $this->mPrinter->getWantsHelp() || $this->mAction == 'help' )
ApiResult :: setContent( $errMessage, $this->makeHelpMsg() );
// Only print the help message when this is for the developer, not runtime
if ( $this->mPrinter->getWantsHelp() || $this->mAction == 'help' )
ApiResult :: setContent( $errMessage, $this->makeHelpMsg() );
} else {
global $wgShowSQLErrors, $wgShowExceptionDetails;
//
// Something is seriously wrong
//
if ( ( $e instanceof DBQueryError ) && !$wgShowSQLErrors ) {
$info = "Database query error";
} else {
global $wgShowSQLErrors, $wgShowExceptionDetails;
//
// Something is seriously wrong
//
if ( ( $e instanceof DBQueryError ) && !$wgShowSQLErrors ) {
$info = "Database query error";
} else {
$info = "Exception Caught: {$e->getMessage()}";
}
$errMessage = array (
'code' => 'internal_api_error_' . get_class( $e ),
'info' => $info,
);
ApiResult :: setContent( $errMessage, $wgShowExceptionDetails ? "\n\n{$e->getTraceAsString()}\n\n" : "" );
$info = "Exception Caught: {$e->getMessage()}";
}
$this->getResult()->reset();
$this->getResult()->disableSizeCheck();
// Re-add the id
$requestid = $this->getParameter( 'requestid' );
if ( !is_null( $requestid ) )
$this->getResult()->addValue( null, 'requestid', $requestid );
$this->getResult()->addValue( null, 'error', $errMessage );
$errMessage = array (
'code' => 'internal_api_error_' . get_class( $e ),
'info' => $info,
);
ApiResult :: setContent( $errMessage, $wgShowExceptionDetails ? "\n\n{$e->getTraceAsString()}\n\n" : "" );
}
$this->getResult()->reset();
$this->getResult()->disableSizeCheck();
// Re-add the id
$requestid = $this->getParameter( 'requestid' );
if ( !is_null( $requestid ) )
$this->getResult()->addValue( null, 'requestid', $requestid );
$this->getResult()->addValue( null, 'error', $errMessage );
return $errMessage['code'];
}