Index: trunk/extensions/Translate/utils/TranslationHelpers.php |
— | — | @@ -297,7 +297,7 @@ |
298 | 298 | self::reportTranslationServiceFailure( $serviceName ); |
299 | 299 | } elseif ( !is_array( $response ) ) { |
300 | 300 | error_log( __METHOD__ . ': Unable to parse reply: ' . strval( $json ) ); |
301 | | - return null; |
| 301 | + throw new TranslationHelperExpection( 'Malformed reply from remote server' ); |
302 | 302 | } |
303 | 303 | |
304 | 304 | $suggestions = $response['ttmserver']; |
— | — | @@ -369,7 +369,7 @@ |
370 | 370 | |
371 | 371 | /** |
372 | 372 | * @param $async bool |
373 | | - * @return null|string |
| 373 | + * @return string |
374 | 374 | * @throws MWException |
375 | 375 | */ |
376 | 376 | public function getSuggestionBox( $async = false ) { |
— | — | @@ -448,7 +448,7 @@ |
449 | 449 | $unsupported = wfGetCache( CACHE_ANYTHING )->get( $memckey ); |
450 | 450 | |
451 | 451 | if ( isset( $unsupported[$code] ) ) { |
452 | | - return null; |
| 452 | + throw new TranslationHelperExpection( 'Unsupported language' ); |
453 | 453 | } |
454 | 454 | |
455 | 455 | $options = array(); |
— | — | @@ -462,7 +462,7 @@ |
463 | 463 | if ( isset( $config['key'] ) ) { |
464 | 464 | $params['appId'] = $config['key']; |
465 | 465 | } else { |
466 | | - return null; |
| 466 | + throw new TranslationHelperExpection( 'API key is not set' ); |
467 | 467 | } |
468 | 468 | |
469 | 469 | $url = $config['url'] . '?' . wfArrayToCgi( $params ); |
— | — | @@ -483,7 +483,7 @@ |
484 | 484 | if ( strpos( $error, 'must be a valid language' ) !== false ) { |
485 | 485 | $unsupported[$code] = true; |
486 | 486 | wfGetCache( CACHE_ANYTHING )->set( $memckey, $unsupported, 60 * 60 * 8 ); |
487 | | - return null; |
| 487 | + throw new TranslationHelperExpection( 'Unsupported language code' ); |
488 | 488 | } |
489 | 489 | |
490 | 490 | if ( $error ) { |
— | — | @@ -536,7 +536,7 @@ |
537 | 537 | self::reportTranslationServiceFailure( $serviceName ); |
538 | 538 | } elseif ( !is_object( $response ) ) { |
539 | 539 | error_log( __METHOD__ . ': Unable to parse reply: ' . strval( $json ) ); |
540 | | - return null; |
| 540 | + throw new TranslationHelperExpection( 'Malformed reply from remote server' ); |
541 | 541 | } |
542 | 542 | |
543 | 543 | foreach ( $response->responseData as $pair ) { |
— | — | @@ -558,7 +558,7 @@ |
559 | 559 | $code = str_replace( '-', '_', wfBCP47( $code ) ); |
560 | 560 | |
561 | 561 | if ( !isset( $pairs[$code] ) ) { |
562 | | - return null; |
| 562 | + throw new TranslationHelperExpection( 'Unsupported language' ); |
563 | 563 | } |
564 | 564 | |
565 | 565 | $suggestions = array(); |
— | — | @@ -601,7 +601,7 @@ |
602 | 602 | } |
603 | 603 | |
604 | 604 | if ( !count( $suggestions ) ) { |
605 | | - return null; |
| 605 | + throw new TranslationHelperExpection( 'No suggestions' ); |
606 | 606 | } |
607 | 607 | |
608 | 608 | $divider = Html::element( 'div', array( 'style' => 'margin-bottom: 0.5ex' ) ); |
— | — | @@ -771,7 +771,7 @@ |
772 | 772 | global $wgTranslateDocumentationLanguageCode, $wgOut; |
773 | 773 | |
774 | 774 | if ( !$wgTranslateDocumentationLanguageCode ) { |
775 | | - return null; |
| 775 | + throw new TranslationHelperExpection( 'Message documentation language code is not defined' ); |
776 | 776 | } |
777 | 777 | |
778 | 778 | $page = $this->handle->getKey(); |