Skip to content

Print out more info #3

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
merged 2 commits into from
Mar 3, 2017
Merged

Print out more info #3

merged 2 commits into from
Mar 3, 2017

Conversation

jvictorchen
Copy link

Print out the name of the requested type, and the ambiguous implementations when panicking. This will be helpful for debugging.

@@ -183,7 +183,7 @@ func (i *injector) Get(t reflect.Type) reflect.Value {
}
}
if len(impls) > 1 && i.options.PanicOnAmbiguity {
panic(fmt.Sprintf("Expect single matching implementation but found %v", len(impls)))
panic(fmt.Sprintf("Expected single matching implementation for type <%v> but found %v: %v", t, len(impls), impls))

Choose a reason for hiding this comment

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

Does reflect.Value stringify nicely for all types? The documentation for reflect.Value's String() method (https://golang.org/pkg/reflect/#Value.String) says "The fmt package treats Values specially. It does not call their String method implicitly but instead prints the concrete values they hold.", but your test seems to indicate it prints the type, so I don't know what to believe anymore.

Copy link
Author

Choose a reason for hiding this comment

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

Hmm not sure why fmt package is not doing what it says, but from what I see, Value is printed as where T is v's type. So that suggests fmt package is calling String() method?

@jvictorchen jvictorchen merged commit 78dabaf into master Mar 3, 2017
@jvictorchen jvictorchen deleted the print-out-more-info branch March 3, 2017 03:35
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