Skip to content

Commit b096c2b

Browse files
authored
Adds descriptive error when failing to make concrete (#51)
If using lazy loading and the call to a resolver when making a concrete fails, that error wasn't wrapped and caused confusion since we didn't know which abstraction we were attempting to satisfy. Wrapping error so we know that: a) Error occurred during resolve call. b) What abstraction we were trying to resolve. This should make it easier to debug these failures in lazy loading situations.
1 parent db44bd9 commit b096c2b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

container.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ func (c Container) NamedResolve(abstraction interface{}, name string) error {
239239
reflect.ValueOf(abstraction).Elem().Set(reflect.ValueOf(instance))
240240
return nil
241241
} else {
242-
return err
242+
return fmt.Errorf("container: encountered error while making concrete for: %s. Error encountered: %w", elem.String(), err)
243243
}
244244
}
245245

0 commit comments

Comments
 (0)