Skip to content
This repository was archived by the owner on Nov 14, 2019. It is now read-only.

Commit 8e51180

Browse files
author
Emil Andersson
committed
Intercept and customize error from Guzzle
When guzzle is initalized it tried to find a suitable handler to use. If no handler can be found (for example curl) an exception is thrown. With this change we try to find the handler before creating the client so we can pass the handler to the client manually. Doing this, we are able to customize the error message to make it (potentially) less confusing for the users who might have no idea what guzzle is.
1 parent 91e8814 commit 8e51180

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Symfony/Installer/DownloadCommand.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use GuzzleHttp\Client;
2020
use GuzzleHttp\Exception\ClientException;
2121
use GuzzleHttp\Event\ProgressEvent;
22+
use GuzzleHttp\Utils;
2223
use Symfony\Component\Console\Command\Command;
2324
use Symfony\Component\Console\Helper\ProgressBar;
2425
use Symfony\Component\Console\Input\InputInterface;
@@ -221,7 +222,15 @@ protected function getGuzzleClient()
221222
$defaults['debug'] = true;
222223
}
223224

224-
return new Client(array('defaults' => $defaults));
225+
try {
226+
$handler = Utils::getDefaultHandler();
227+
} catch (\RuntimeException $e) {
228+
throw new \RuntimeException(
229+
'The Symfony installer requires the php-curl extension or the '
230+
.'allow_url_fopen ini setting.');
231+
}
232+
233+
return new Client(array('defaults' => $defaults, 'handler' => $handler));
225234
}
226235

227236
/**

0 commit comments

Comments
 (0)