Parcourir la source

Fix exception handling

Jordi Boggiano il y a 13 ans
Parent
commit
7285536737
2 fichiers modifiés avec 11 ajouts et 6 suppressions
  1. 8 3
      src/Composer/Repository/Vcs/SvnDriver.php
  2. 3 3
      src/Composer/Util/Svn.php

+ 8 - 3
src/Composer/Repository/Vcs/SvnDriver.php

@@ -17,6 +17,7 @@ use Composer\Util\ProcessExecutor;
 use Composer\Util\Filesystem;
 use Composer\Util\Svn as SvnUtil;
 use Composer\IO\IOInterface;
+use Composer\Downloader\TransportException;
 
 /**
  * @author Jordi Boggiano <j.boggiano@seld.be>
@@ -128,9 +129,13 @@ class SvnDriver extends VcsDriver
                 $rev = '';
             }
 
-            $output = $this->execute('svn cat', $this->baseUrl . $identifier . 'composer.json' . $rev);
-            if (!trim($output)) {
-                return;
+            try {
+                $output = $this->execute('svn cat', $this->baseUrl . $identifier . 'composer.json' . $rev);
+                if (!trim($output)) {
+                    return;
+                }
+            } catch (\RuntimeException $e) {
+                throw new TransportException($e->getMessage());
             }
 
             $composer = JsonFile::parseJson($output);

+ 3 - 3
src/Composer/Util/Svn.php

@@ -89,13 +89,13 @@ class Svn
 
         // the error is not auth-related
         if (false === stripos($output, 'authorization failed:')) {
-            throw new \RuntimeException('Package could not be downloaded: '.$output);
+            throw new \RuntimeException($output);
         }
 
         // no auth supported for non interactive calls
         if (!$this->io->isInteractive()) {
             throw new \RuntimeException(
-                'Package could not be downloaded, can not ask for authentication in non interactive mode ('.$output.')'
+                'can not ask for authentication in non interactive mode ('.$output.')'
             );
         }
 
@@ -111,7 +111,7 @@ class Svn
         }
 
         throw new \RuntimeException(
-            'Repository '.$this->url.' could not be processed, wrong credentials provided ('.$output.')'
+            'wrong credentials provided ('.$output.')'
         );
     }