Skip to content

Commit

Permalink
Adds descriptive error when failing to make concrete (#51)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wirecat authored Apr 12, 2023
1 parent db44bd9 commit b096c2b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion container.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func (c Container) NamedResolve(abstraction interface{}, name string) error {
reflect.ValueOf(abstraction).Elem().Set(reflect.ValueOf(instance))
return nil
} else {
return err
return fmt.Errorf("container: encountered error while making concrete for: %s. Error encountered: %w", elem.String(), err)
}
}

Expand Down

0 comments on commit b096c2b

Please sign in to comment.