Improve exception messages #326

Merged
merged 4 commits into from Sep 18, 2015

Conversation

Projects
None yet
1 participant
@mnapoli
Member

mnapoli commented Sep 16, 2015

Improve exception messages: simpler and more consistent. Added more tests too.


Before

Entry DI\Test\IntegrationTest\ErrorMessages\Buggy1 cannot be resolved: The parameter 'bar' of DI\Test\IntegrationTest\ErrorMessages\Buggy1::__construct has no value defined or guessable
Object (
    class = DI\Test\IntegrationTest\ErrorMessages\Buggy1
    scope = singleton
    lazy = false
    __construct(
        $foo = 'some value'
        $bar = #UNDEFINED#
        $default = (default value) 123
    )
)

After

Entry "DI\Test\IntegrationTest\ErrorMessages\Buggy1" cannot be resolved: Parameter $bar of __construct() has no value defined or guessable
Object (
    class = DI\Test\IntegrationTest\ErrorMessages\Buggy1
    scope = singleton
    lazy = false
    __construct(
        $foo = 'some value'
        $bar = #UNDEFINED#
        $default = (default value) 123
    )
)

Before

Entry DI\Test\IntegrationTest\ErrorMessages\InterfaceFixture cannot be resolved: class DI\Test\IntegrationTest\ErrorMessages\InterfaceFixture is not instantiable
Full definition:
Object (
    class = #NOT INSTANTIABLE# DI\Test\IntegrationTest\ErrorMessages\InterfaceFixture
    scope = singleton
    lazy = false
)

After

Entry "DI\Test\IntegrationTest\ErrorMessages\InterfaceFixture" cannot be resolved: the class is not instantiable
Full definition:
Object (
    class = #NOT INSTANTIABLE# DI\Test\IntegrationTest\ErrorMessages\InterfaceFixture
    scope = singleton
    lazy = false
)

Before

The factory definition "Acme\UserRepository" is not callable: RepositoryFactory is neither a callable or a valid container entry

After

Entry "Acme\UserRepository" cannot be resolved: factory "RepositoryFactory" is neither a callable nor a valid container entry

@mnapoli mnapoli added the enhancement label Sep 16, 2015

@mnapoli mnapoli added this to the 5.2 milestone Sep 16, 2015

mnapoli added some commits Sep 17, 2015

mnapoli added a commit that referenced this pull request Sep 18, 2015

@mnapoli mnapoli merged commit 0cfa9fd into master Sep 18, 2015

4 checks passed

Scrutinizer 1 new issues
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.4%) to 85.091%
Details

@mnapoli mnapoli deleted the exception_messages branch Sep 18, 2015

jdreesen added a commit to jdreesen/PHP-DI that referenced this pull request Sep 19, 2015

@jdreesen jdreesen referenced this pull request Sep 19, 2015

Merged

Some cleanup #328

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment