Merge "Cleanup some incorrect return annotations"
[lhc/web/wiklou.git] / includes / api / ApiQueryStashImageInfo.php
index 6d1540b..abb827f 100644 (file)
@@ -32,6 +32,10 @@ class ApiQueryStashImageInfo extends ApiQueryImageInfo {
        }
 
        public function execute() {
+               if ( !$this->getUser()->isLoggedIn() ) {
+                       $this->dieWithError( 'apierror-mustbeloggedin-uploadstash', 'notloggedin' );
+               }
+
                $params = $this->extractRequestParams();
                $modulePrefix = $this->getModulePrefix();
 
@@ -41,9 +45,7 @@ class ApiQueryStashImageInfo extends ApiQueryImageInfo {
 
                $result = $this->getResult();
 
-               if ( !$params['filekey'] && !$params['sessionkey'] ) {
-                       $this->dieUsage( 'One of filekey or sessionkey must be supplied', 'nofilekey' );
-               }
+               $this->requireAtLeastOneParameter( $params, 'filekey', 'sessionkey' );
 
                // Alias sessionkey to filekey, but give an existing filekey precedence.
                if ( !$params['filekey'] && $params['sessionkey'] ) {
@@ -62,9 +64,9 @@ class ApiQueryStashImageInfo extends ApiQueryImageInfo {
                        }
                // @todo Update exception handling here to understand current getFile exceptions
                } catch ( UploadStashFileNotFoundException $e ) {
-                       $this->dieUsage( 'File not found: ' . $e->getMessage(), 'invalidsessiondata' );
+                       $this->dieWithException( $e, [ 'wrap' => 'apierror-stashedfilenotfound' ] );
                } catch ( UploadStashBadPathException $e ) {
-                       $this->dieUsage( 'Bad path: ' . $e->getMessage(), 'invalidsessiondata' );
+                       $this->dieWithException( $e, [ 'wrap' => 'apierror-stashpathinvalid' ] );
                }
        }