Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make provide's errors more expressive for fx.Annotate-ed functions #844

Merged
merged 7 commits into from Feb 22, 2022

Conversation

josephinedotlee
Copy link
Contributor

Because of the use of reflection in fx.Annotate, the error
messages for provide tend to refer to the annotated function as
"reflect".makeFuncStub which is not helpful for debugging.

This change updates error messages that previously looked like:

Failed: cannot provide function "reflect".makeFuncStub (/usr/local/go/src/reflect/asm_arm64.s:12):
cannot provide *fx_test.Logger from [0].Field0: already provided by "reflect".makeFuncStub
(/usr/local/go/src/reflect/asm_arm64.s:12)

To looking like this:

Failed: cannot provide function "reflect".makeFuncStub (/usr/local/go/src/reflect/asm_amd64.s:12):
cannot provide *fx_test.Logger from [0].Field0: already provided by "go.uber.org/fx_test".TestAnnotate.func1
(/gocode/src/github.com/uber-go/fx/annotated_test.go:515)

WIP: Planning on making a future fix that gives a more
readable name to the first function which still is referred to
as "reflect".makeFuncStub after this change.

Because of the use of reflection in fx.Annotate, the error
messages for provide tend to refer to the annotated function as
`"reflect".makeFuncStub` which is not helpful for debugging.

This change updates error messages that previously looked like:
```
Failed: cannot provide function "reflect".makeFuncStub (/usr/local/go/src/reflect/asm_arm64.s:12):
cannot provide *fx_test.Logger from [0].Field0: already provided by "reflect".makeFuncStub
(/usr/local/go/src/reflect/asm_arm64.s:12)
```

To looking like this:
```
Failed: cannot provide function "reflect".makeFuncStub (/usr/local/go/src/reflect/asm_amd64.s:12):
cannot provide *fx_test.Logger from [0].Field0: already provided by "go.uber.org/fx_test".TestAnnotate.func1
(/gocode/src/github.com/uber-go/fx/annotated_test.go:515)
```

WIP: Planning on making a future fix that gives a more
readable name to the first function which still is referred to
as "reflect".makeFuncStub after this change.
@josephinedotlee josephinedotlee linked an issue Feb 18, 2022 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Feb 18, 2022

Codecov Report

Merging #844 (8ee7e13) into master (15dc60c) will increase coverage by 0.18%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #844      +/-   ##
==========================================
+ Coverage   98.45%   98.63%   +0.18%     
==========================================
  Files          30       30              
  Lines        1098     1100       +2     
==========================================
+ Hits         1081     1085       +4     
+ Misses         11       10       -1     
+ Partials        6        5       -1     
Impacted Files Coverage Δ
annotated.go 99.39% <100.00%> (+<0.01%) ⬆️
provide.go 100.00% <100.00%> (ø)
app.go 95.87% <0.00%> (+0.91%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 15dc60c...8ee7e13. Read the comment docs.

annotated.go Outdated Show resolved Hide resolved
annotated.go Outdated Show resolved Hide resolved
annotated_test.go Outdated Show resolved Hide resolved
provide.go Outdated Show resolved Hide resolved
josephinedotlee and others added 4 commits February 18, 2022 13:42
Co-authored-by: Moises Vega <moises.vega@gmail.com>
Co-authored-by: Moises Vega <moises.vega@gmail.com>
Co-authored-by: Moises Vega <moises.vega@gmail.com>
Co-authored-by: Moises Vega <moises.vega@gmail.com>
Copy link
Contributor

@sywhang sywhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address the linter error before merging. Also it'd be nice if you can edit the commit message here to mention that the "other half" of the error message that wasn't fixed by this PR is due to an issue in Dig and will be addressed in follow-up work in Dig.

@josephinedotlee josephinedotlee merged commit 7bb5b40 into master Feb 22, 2022
@josephinedotlee josephinedotlee deleted the fx.Annotate-provide-err-messages branch February 22, 2022 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Provide errors from Annotated functions are cryptic
3 participants