Merge "DifferenceEngine: Don't display empty header row"
[lhc/web/wiklou.git] / includes / api / ApiUpload.php
index 8f71fbe..34741b5 100644 (file)
@@ -61,10 +61,14 @@ class ApiUpload extends ApiBase {
                }
 
                // Select an upload module
-               if ( !$this->selectUploadModule() ) {
-                       return; // not a true upload, but a status request or similar
-               } elseif ( !isset( $this->mUpload ) ) {
-                       $this->dieUsage( 'No upload module set', 'nomodule' );
+               try {
+                       if ( !$this->selectUploadModule() ) {
+                               return; // not a true upload, but a status request or similar
+                       } elseif ( !isset( $this->mUpload ) ) {
+                               $this->dieUsage( 'No upload module set', 'nomodule' );
+                       }
+               } catch ( UploadStashException $e ) { // XXX: don't spam exception log
+                       $this->dieUsage( get_class( $e ) . ": " . $e->getMessage(), 'stasherror' );
                }
 
                // First check permission to upload
@@ -106,9 +110,13 @@ class ApiUpload extends ApiBase {
                }
 
                // Get the result based on the current upload context:
-               $result = $this->getContextResult();
-               if ( $result['result'] === 'Success' ) {
-                       $result['imageinfo'] = $this->mUpload->getImageInfo( $this->getResult() );
+               try {
+                       $result = $this->getContextResult();
+                       if ( $result['result'] === 'Success' ) {
+                               $result['imageinfo'] = $this->mUpload->getImageInfo( $this->getResult() );
+                       }
+               } catch ( UploadStashException $e ) { // XXX: don't spam exception log
+                       $this->dieUsage( get_class( $e ) . ": " . $e->getMessage(), 'stasherror' );
                }
 
                $this->getResult()->addValue( null, $this->getModuleName(), $result );
@@ -807,6 +815,7 @@ class ApiUpload extends ApiBase {
                                array( 'code' => 'publishfailed', 'info' => 'Publishing of stashed file failed' ),
                                array( 'code' => 'internal-error', 'info' => 'An internal error occurred' ),
                                array( 'code' => 'asynccopyuploaddisabled', 'info' => 'Asynchronous copy uploads disabled' ),
+                               array( 'code' => 'stasherror', 'info' => 'An upload stash error occurred' ),
                                array( 'fileexists-forbidden' ),
                                array( 'fileexists-shared-forbidden' ),
                        )