Skip to content

feat(golang): implement exception classname metadata extraction #9

Description

@pleberre

Problem

The Go parser does not extract exception classname metadata, resulting in incomplete error tracking data.

File Location

src/main/java/io/err0/client/languages/GolangSourceCodeParse.java:324

// TODO: extract exception classname meta data

Context

Go uses explicit error handling with the error interface:

// Standard error returns
func doSomething() error {
    return errors.New("something went wrong")
}

// Custom error types
type MyError struct {
    message string
}

// Error interface implementation
func (e *MyError) Error() string {
    return e.message
}

// Standard library errors
return fmt.Errorf("failed: %w", err)

Expected Behavior

Extract and store:

  • Error type names from return signatures
  • Custom error struct names
  • Standard library error types
  • Wrapped error information

Implementation Guidance

  1. Identify Go error patterns:

    • error return types
    • errors.New() calls
    • fmt.Errorf() calls
    • Custom error struct definitions
    • Error type assertions
  2. Extract error information:

    • For custom types: extract struct name
    • For standard errors: mark as "error"
    • For wrapped errors: extract wrapped type if available
  3. Store in token metadata

  4. Handle Go's convention of returning (result, error) tuples

Test Cases Needed

Add to src/test/testdata/ for Go:

  • Function returning error
  • Custom error type
  • errors.New() usage
  • fmt.Errorf() usage
  • Error wrapping with %w

Reference Files

  • src/main/java/io/err0/client/languages/JavaSourceCodeParse.java (exception pattern reference)
  • Existing Go test data in src/test/testdata/

Acceptance Criteria

  • Error type names extracted from Go error patterns
  • Metadata field populated with error information
  • TODO removed from GolangSourceCodeParse.java:324
  • Tests pass for Go error handling
  • No regressions in existing Go parsing

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions