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.

Intercept and customize error from Guzzle #226

Merged

Conversation

emil-nasso
Copy link
Contributor

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

@emil-nasso emil-nasso force-pushed the guzzle-intercept-error-message branch from 6ef89ad to ef91ce2 Compare December 10, 2015 21:35
$handler = Utils::getDefaultHandler();
} catch (\RuntimeException $e) {
throw new \RuntimeException(
'The symfony installer requires the php-curl extension or the '
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Symfony

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xabbuh fixed

@emil-nasso emil-nasso force-pushed the guzzle-intercept-error-message branch from ef91ce2 to 8e51180 Compare December 14, 2015 13:41
$handler = Utils::getDefaultHandler();
} catch (\RuntimeException $e) {
throw new \RuntimeException(
'The Symfony installer requires the php-curl extension or the '
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think wrapping this message is the best idea for code style :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linebreak? Removed it. It's < 120 characters wide. :)

@emil-nasso emil-nasso force-pushed the guzzle-intercept-error-message branch from 8e51180 to ea2c961 Compare December 14, 2015 13:47
$handler = Utils::getDefaultHandler();
} catch (\RuntimeException $e) {
throw new \RuntimeException(
'The Symfony installer requires the php-curl extension or the allow_url_fopen ini setting.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

); should be on the next line, or keep everything inlined with the \RuntimeException constructor call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@emil-nasso emil-nasso force-pushed the guzzle-intercept-error-message branch from ea2c961 to 3a5b5ca Compare December 15, 2015 08:41
WORKDIR /root/shared
RUN apt-get update && apt-get install -y php5-cli

ENTRYPOINT /bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really needed to have a dockerfile in this repo actually?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow. I can't do this right.... I accidentally committed it. Really sorry... Removed.

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.
@emil-nasso emil-nasso force-pushed the guzzle-intercept-error-message branch from 3a5b5ca to 951732b Compare December 15, 2015 08:46
@javiereguiluz
Copy link
Member

@emil-nasso I love it when an application displays meaningful error messages. Thanks for helping us improving the Installer error messages.

@javiereguiluz javiereguiluz merged commit 951732b into symfony:master Dec 17, 2015
javiereguiluz added a commit that referenced this pull request Dec 17, 2015
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.
@emil-nasso emil-nasso deleted the guzzle-intercept-error-message branch December 18, 2015 07:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.