Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Nov 14, 2019. It is now read-only.

Commit c1b71a9

Browse filesBrowse files
committed
minor #226 Intercept and customize error from Guzzle (emil-nasso)
This PR was merged into the 1.0-dev branch. Discussion ---------- Intercept and customize error from Guzzle When guzzle is initalized it tries 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 that 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. The issue was found when looking at PR #200 Commits ------- 951732b 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.
2 parents 1baa256 + 951732b commit c1b71a9
Copy full SHA for c1b71a9

File tree

Expand file treeCollapse file tree

1 file changed

+10
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-1
lines changed

‎src/Symfony/Installer/DownloadCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Installer/DownloadCommand.php
+10-1Lines 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 allow_url_fopen ini setting.'
230+
);
231+
}
232+
233+
return new Client(array('defaults' => $defaults, 'handler' => $handler));
225234
}
226235

227236
/**

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.