Skip to content
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

[DependencyInjection] Improve an exception message #33092

Merged
merged 1 commit into from Aug 9, 2019

Conversation

@fabpot
Copy link
Member

commented Aug 9, 2019

Q A
Branch? 4.3
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR n/a

When defining a service with an id that is also a class name, you might have an error message like Class “” used for service “\App\Some\Service” cannot be found. if your is starts with a backslash.

The new error message is now hopefully less cryptic: Service definition "\App\Some\Service" has no class, and its name looks like a FQCN but it starts with a backslash; remove the leading backslash.

@fabpot fabpot merged commit 3647cca into symfony:4.3 Aug 9, 2019

1 of 3 checks passed

continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
fabbot.io Your code looks good.
Details

fabpot added a commit that referenced this pull request Aug 9, 2019

bug #33092 [DependencyInjection] Improve an exception message (fabpot)
This PR was merged into the 4.3 branch.

Discussion
----------

[DependencyInjection] Improve an exception message

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

When defining a service with an id that is also a class name, you might have an error message like `Class “” used for service “\App\Some\Service” cannot be found.` if your is starts with a backslash.

The new error message is now hopefully less cryptic: `Service definition "\App\Some\Service" has no class, and its name looks like a FQCN but it starts with a backslash; remove the leading backslash.`

Commits
-------

3647cca [DependencyInjection] improved exception message
@ro0NL

This comment has been minimized.

Copy link
Contributor

commented Aug 10, 2019

i was curious about doing it in ResolveClassPass (vs. CheckDefinitionValidityPass from #28057)

class Kernel extends BaseKernel implements CompilerPassInterface
{
    public function process(ContainerBuilder $c)
    {
        dd($c->getDefinition('\\Foo\\Bar'));
    }

this now breaks :) so perhaps target 4.4? Alternatively cant we fix it in 3.4 at a later stage (i.e. during optimization instead of before)?

Maybe this is too much an edge case, but then 3.4 was fine also 😅 (though 4.3 is fairly new). Just wanted to share this :)

nicolas-grekas added a commit to nicolas-grekas/symfony that referenced this pull request Aug 10, 2019

Revert "bug symfony#33092 [DependencyInjection] Improve an exception …
…message (fabpot)"

This reverts commit 2f2d1aa, reversing
changes made to 07cf927.

nicolas-grekas added a commit to nicolas-grekas/symfony that referenced this pull request Aug 10, 2019

Revert "bug symfony#33092 [DependencyInjection] Improve an exception …
…message (fabpot)"

This reverts commit 2f2d1aa, reversing
changes made to 07cf927.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.