Skip to content

fix(extgen): better error handling#2370

Open
dunglas wants to merge 2 commits intomainfrom
fix/extgen-error-handling
Open

fix(extgen): better error handling#2370
dunglas wants to merge 2 commits intomainfrom
fix/extgen-error-handling

Conversation

@dunglas
Copy link
Copy Markdown
Member

@dunglas dunglas commented Apr 23, 2026

Superseeds #2351.

Use errors.Join() to preserve all errors in extgen.

Copy link
Copy Markdown
Member

@alexandre-daubois alexandre-daubois left a comment

Choose a reason for hiding this comment

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

I didn't know that. Thanks!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the internal/extgen parsing pipeline to preserve both parsing/scanning errors and Close() errors by switching deferred file-closing logic to errors.Join(), and adjusts related tests’ temp-file cleanup assertions.

Changes:

  • Replace deferred Close() error handling with errors.Join() in several extgen parsers.
  • Remove fmt.Printf-based close-error logging (namespace parser) in favor of error propagation.
  • Simplify test cleanup by using require.NoError for temp-file removal and removing an unused assert import.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/extgen/nsparser.go Attempts to join Close() errors with existing errors (currently ineffective due to unnamed return / returning scanner.Err() directly).
internal/extgen/funcparser.go Uses errors.Join() in deferred Close() to preserve both parse and close errors.
internal/extgen/constparser.go Uses errors.Join() in deferred Close() to preserve both parse and close errors.
internal/extgen/classparser.go Uses errors.Join() in deferred Close() to preserve both parse and close errors in method parsing.
internal/extgen/namespace_test.go Uses require for cleanup and removes unused assert import.
internal/extgen/cfile_namespace_test.go Uses require for cleanup in the temp-file test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/extgen/nsparser.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants