wire
wire copied to clipboard
Better error messages
Is your feature request related to a problem? Please describe.
It's a go convention not to start a variable name in a package with the package name, which means that config
should export config.Provider
not config.ConfigProvider
. However, wire doesn't include the package name in error messages which forces us to name providers package.PackageProvider
for error visibility.
When combined with other generation tools (e.g. proto3), sometimes interfaces are renamed or moved during code generation. The wire error message just refers to the missing interface as invalid type
, which is not very useful for debugging.
Describe the solution you'd like
-
Error messages referring to a provider should contain the full variable path including the package name (e.g.
config.Provider
instead of justProvider
) -
Error messages referring to an invalid type should include the raw text name of that type. Example:
init(s ServiceA){
...
}
Current error:
inject init: no provider found for invalid type
Improved error:
inject init: no provider found for invalid type (ServiceA)
Describe alternatives you've considered
For the first problem, the alternative is to include package names in the provider var name as per the example. For the second problem, there are no alternatives to wire printing the interface name.