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

Make failed autowiring error messages more explicit #18766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

lemoinem
Copy link
Contributor

@lemoinem lemoinem commented May 12, 2016

Q A
Branch? master
Bug fix? no (better DX integration)
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #18658
License MIT
Doc PR N/A

@nicolas-grekas This is a port from #18691 (which was for 2.8).
It looks like the original PR has been already mostly implemented in master by @weaverryan (in #17877).

IMO, this PR is still improving two use cases:

  • In case a class cannot be autowired because no service can be found AND a service cannot be registered automatically, the error message now mentions both conditions (instead of simply saying no service has been found)
  • In case a class with no service attached to it can be automatically instantiated but cannot be autowired because of further problems, an exception mentioning this is now thrown instead of the lower level exception, making the situation easier to debug. (The lower level exception is still available through getPrevious())

Hence, I still think this PR provides useful additional DX features and is worth to be merged.

@nicolas-grekas
Copy link
Member

Thanks!
It would be great if you could make the exception messages the same in 3.0 and 3.1 (when applicable).

@lemoinem
Copy link
Contributor Author

lemoinem commented May 12, 2016

No problem, which messages are better? Would you prefer me to update the ones in 2.8/3.0 to Ryan's messages or to change this PR to re-use the ones I defined in my previous PR?

IMHO, I think the ones in this PR are better than the one from my first PR, so I'd think updating 2.8/3.0 would be better...

@javiereguiluz javiereguiluz added DependencyInjection DX DX = Developer eXperience (anything that improves the experience of using Symfony) labels May 12, 2016
@fabpot
Copy link
Member

fabpot commented May 13, 2016

Thank you @lemoinem.

@fabpot fabpot merged commit 6894e03 into symfony:master May 13, 2016
fabpot added a commit that referenced this pull request May 13, 2016
…nem)

This PR was merged into the 3.1-dev branch.

Discussion
----------

Make failed autowiring error messages more explicit

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no (better DX integration)
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #18658
| License       | MIT
| Doc PR        | N/A

@nicolas-grekas This is a port from #18691 (which was for **2.8**).
It looks like the original PR has been already mostly implemented in **master** by @weaverryan (in #17877).

IMO, this PR is still improving two use cases:

  * In case a class cannot be autowired because no service can be found AND a service cannot be registered automatically, the error message now mentions both conditions (instead of simply saying no service has been found)
  * In case a class with no service attached to it can be automatically instantiated but cannot be autowired because of further problems, an exception mentioning this is now thrown instead of the lower level exception, making the situation easier to debug. (The lower level exception is still available through `getPrevious()`)

Hence, I still think this PR provides useful additional DX features and is worth to be merged.

Commits
-------

6894e03 Make failed autowiring error messages more explicit
@nicolas-grekas
Copy link
Member

@lemoinem please do what you think is best

@fabpot fabpot mentioned this pull request May 13, 2016
@lemoinem lemoinem deleted the fix/autowiring/exception-message-3.1 branch May 13, 2016 18:37
nicolas-grekas added a commit that referenced this pull request May 19, 2016
…e future friendly (lemoinem)

This PR was merged into the 2.8 branch.

Discussion
----------

[DX][DependencyInjection] Make Autowiring exceptions more future friendly

| Q             | A
| ------------- | ---
| Branch?       | 2.8, 3.0
| Bug fix?      | no (forward compatibility)
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | N/A
| License       | MIT
| Doc PR        | N/A

This is a follow-up on #18766 (3.1, master) and #18691 (2.8, 3.0).

This PR changes the exception messages to the ones introduced in #18766 and #17877. I also unified the tests so they are exactly the same.

This way the error messages will be the same in 2.8 onward.

Commits
-------

834f550 [DX][DI] Make Autowiring exceptions more future friendly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DependencyInjection DX DX = Developer eXperience (anything that improves the experience of using Symfony) Status: Needs Review
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.