refactor(xerrors): structured desc rendering and format improvements#387
Open
refactor(xerrors): structured desc rendering and format improvements#387
Conversation
- Add NewDesc(err) to extract structured fields from error chain - Add fieldsCarrier interface for structured key-value field access - Add withMessage.replacesCause to allow message to fully replace cause text - Format %+v now renders NewDesc(err).String() + stack trace - Format Error()/%v/%s only renders the plain reason/error text - Remove unused cause parameter from format() function signature - Improve test coverage: add meaningful %+v test cases with ecode errors showing real difference from %s/%v (structured desc vs plain text) - assertError now verifies %+v starts with NewDesc(err).String() - func_test.go: use require.NoErrorf with NewDesc for rich error output
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #387 +/- ##
==========================================
+ Coverage 74.05% 74.28% +0.22%
==========================================
Files 87 88 +1
Lines 8819 9100 +281
==========================================
+ Hits 6531 6760 +229
- Misses 1718 1768 +50
- Partials 570 572 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…dsRenderer interface
…fix lint warnings
Kybxd
reviewed
Apr 15, 2026
| } | ||
| } | ||
|
|
||
| // ScatterAndExport |
| sheetBeginTime := time.Now() | ||
| if specifiedSheetName != "" { | ||
| if specifiedSheetName != sheetName { | ||
| continue sheetLoop |
| // NOTE: the global options has been merged into book options on protogen, | ||
| // so there is no need to set it here. | ||
| header := tableparser.NewHeader(p.sheetOpts, p.bookOpts, nil) | ||
| err := tableparser.RangeDataRows(table, header, func(r *book.Row) error { |
Collaborator
There was a problem hiding this comment.
tableparser.RangeDataRows fails fast when error occurs, so maybe we should change its iterating logic to adapt to the error collector?
Collaborator
|
Since error collector is passed as function params, should there functions still return an error? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactors the
xerrorspackage intointernal/x/xerrorswith a new structured error collection system supporting multi-level hierarchies.Key Changes
New: Hierarchical Error Collector (
internal/x/xerrors/collector.go)Collectoraccumulates errors concurrently up to a configurable limitglobal → book → sheet → messageNewChild()/Join()for tree-based error aggregationGrouptieserrgroup.Groupto aCollectorfor concurrent collectionRefactored:
xerrors→internal/x/xerrorsdesc.go,errors.go,stack.gointointernal/x/xerrorscontainsMultiError + NewDesctrick withfieldsRendererinterfaceCollectorAPI, cleaned up comments and lint warningsxerrors/top-level packageIntegration Tests
confgencollector integration tests with CSV testdata (normal + overflow cases, multi-workbook)protogencollector integration tests with CSV testdata (normal + overflow cases, multi-workbook)Documentation
internal/confgen/README.md: parsing hierarchy and error collector hierarchy (with Mermaid diagrams)internal/protogen/README.md: parsing hierarchy and error collector hierarchy (with Mermaid diagrams)