Skip to content

Distinguish between unsatisfied constructor and factory method deps #965

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

Closed
wants to merge 1 commit into from

Conversation

wilkinsona
Copy link
Member

As discussed with @snicoll, and in support of Spring Boot 1.4's goal of providing improved diagnostics when application context refresh fails, this PR introduces specific exceptions for unsatisfied factory method dependencies and unsatisfied constructor dependencies.

Previously, an UnsatisfiedDependencyException was thrown when the
dependencies (arguments) of a constructor or a factory method could not
be satisfied. This had two drawbacks:

 1. The exception message for a failure for a factory method
    mentioned constructor arguments.
 2. The catcher of the exception had no way, short of parsing the
    message, to determine the exact nature of the failure.

This commit introduces two new UnsatisfiedDependencyException
subclasses – UnsatisfiedFactoryMethodDependencyException and
UnsatisfiedConstructorDependencyException. Each new exception provides
getters to access the method or constructor, and the index and type
of the unsatisfied argument.
@snicoll
Copy link
Member

snicoll commented Apr 12, 2016

@jhoeller has fixed this one already. Thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants