wire icon indicating copy to clipboard operation
wire copied to clipboard

Better error messages

Open HeshamMeneisi opened this issue 3 years ago • 0 comments

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 just Provider)

  • 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.

HeshamMeneisi avatar Nov 04 '21 03:11 HeshamMeneisi