Skip to content

feat(rust): implement exception classname metadata extraction #8

Description

@pleberre

Problem

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

File Location

src/main/java/io/err0/client/languages/RustSourceCodeParse.java:304

// TODO: extract exception classname meta data

Context

Rust uses Result<T, E> and panic! for error handling:

// Result type errors
let result: Result<i32, MyError> = Err(MyError::new());

// Panic macro
panic!("error message");

// Custom error types
enum MyError {
    NetworkError,
    ParseError(String),
}

Expected Behavior

Extract and store:

  • Error type names from Result<T, E> patterns
  • Enum variant names for error types
  • Custom error struct names
  • Standard library error types (io::Error, etc.)

Implementation Guidance

  1. Identify Rust error patterns:

    • Result<T, E> types
    • panic! macro calls
    • Error enum definitions
    • std::error::Error trait implementations
  2. Extract error type name:

    • For Result<T, MyError>: extract "MyError"
    • For panic!: mark as "panic"
    • For custom enums: extract enum name and variant
  3. Store in token metadata (similar to other languages)

  4. Follow existing patterns from Java exception handling

Test Cases Needed

Add to src/test/testdata/ for Rust:

  • Result type with custom error
  • Panic macro
  • Error enum with variants
  • std library errors

Reference Files

  • src/main/java/io/err0/client/languages/JavaSourceCodeParse.java (exception handling pattern)
  • src/main/java/io/err0/client/languages/GolangSourceCodeParse.java (similar Go error handling)

Acceptance Criteria

  • Exception class names extracted from Rust error patterns
  • Metadata field populated with error type information
  • TODO removed from RustSourceCodeParse.java:304
  • Tests pass for Rust error handling
  • No regressions in existing Rust 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