jmattheis / goverter

Generate type-safe Go converters by simply defining an interface
https://goverter.jmattheis.de/
MIT License
496 stars 46 forks source link

feat: wrapErrors to report field names and slice indexes #29

Closed nissim-natanov-outreach closed 2 years ago

nissim-natanov-outreach commented 2 years ago

This PR introduces the wrapErrors feature to wrap conversion methods with extra troubleshooting information, such as struct field names or slice indexes. The new flag can be set either via command line for the whole generated codebase (this is what we are going to use) or locally via goverter:wrapErrors tag per method.

Reason: we are copying relatively large structs with many fields, and when something fails, it is hard to debug an error that says 'UUID conversion failed' when there are 10 fields that carry UUID. This feature will help us pin point the field that carried the faulty data speeding up the investigation.

@jmattheis Jannis, PTAL.

codecov-commenter commented 2 years ago

Codecov Report

Merging #29 (e482f00) into main (12cc647) will decrease coverage by 0.40%. The diff coverage is 86.53%.

@@            Coverage Diff             @@
##             main      #29      +/-   ##
==========================================
- Coverage   93.74%   93.34%   -0.41%     
==========================================
  Files          22       23       +1     
  Lines        1167     1202      +35     
==========================================
+ Hits         1094     1122      +28     
- Misses         55       60       +5     
- Partials       18       20       +2     
Impacted Files Coverage Δ
cmd/goverter/main.go 0.00% <0.00%> (ø)
comments/parse_docs.go 94.66% <60.00%> (-2.48%) :arrow_down:
builder/basic.go 100.00% <100.00%> (ø)
builder/error_wrapper.go 100.00% <100.00%> (ø)
builder/list.go 100.00% <100.00%> (ø)
builder/map.go 100.00% <100.00%> (ø)
builder/pointer.go 92.85% <100.00%> (+0.17%) :arrow_up:
builder/struct.go 100.00% <100.00%> (ø)
generator/generate.go 93.75% <100.00%> (+0.20%) :arrow_up:
generator/generator.go 97.74% <100.00%> (+0.10%) :arrow_up:
... and 1 more

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 12cc647...e482f00. Read the comment docs.