Skip to content

Commit 78dabaf

Browse files
authored
Print out more info when panic (#3)
* Print out more info when panic * Print out more info when panic on ambiguous implementations
1 parent 8eeec5b commit 78dabaf

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

inject.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func (i *injector) Get(t reflect.Type) reflect.Value {
183183
}
184184
}
185185
if len(impls) > 1 && i.options.PanicOnAmbiguity {
186-
panic(fmt.Sprintf("Expect single matching implementation but found %v", len(impls)))
186+
panic(fmt.Sprintf("Expected single matching implementation for type <%v> but found %v: %v", t, len(impls), impls))
187187
}
188188
if len(impls) > 0 {
189189
val = impls[0]

inject_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func TestInjectImplementors_AmbiguousImplementation(t *testing.T) {
176176
func TestInjectImplementors_AmbiguousImplementationPanic(t *testing.T) {
177177
defer func() {
178178
r := recover()
179-
expect(t, r, "Expect single matching implementation but found 2")
179+
expect(t, r, "Expected single matching implementation for type <fmt.Stringer> but found 2: [<*inject.Greeter Value> <*inject.Greeter2 Value>]")
180180
}()
181181

182182
injector := New()

0 commit comments

Comments
 (0)