Skip to content

Conversation

@wmmc88
Copy link
Collaborator

@wmmc88 wmmc88 commented Aug 25, 2025

This pull request refactors error handling for I/O operations in the wdk-build crate, introducing a dedicated IoError type with richer metadata for better diagnostics and context. It also consolidates directory validation logic and simplifies code paths that manipulate file system resources. The changes improve error reporting, code maintainability, and consistency across the crate.

Error handling improvements:

  • Introduced the IoError and IoErrorMetadata types in crates/wdk-build/src/lib.rs, replacing direct usage of std::io::Error throughout the crate. This provides structured context for I/O failures, such as which paths caused errors. The ConfigError enum now wraps IoError instead of std::io::Error.
  • Updated all file system operations in crates/wdk-build/src/cargo_make.rs (e.g., path resolution, directory creation, file copying, symlink creation, and reading symlinks) to use the new error type and attach relevant path metadata. [1] [2] [3] [4]

Codebase simplification and maintainability:

  • Added a helper method validate_and_add_folder_path to Config in crates/wdk-build/src/lib.rs for validating and normalizing directory paths before adding them to collections, reducing code repetition and standardizing error handling for missing directories and path normalization.
  • Refactored header and library path collection logic to use the new helper method, improving readability and maintainability. [1] [2] [3] [4]

Other changes:

  • Removed the custom HeaderNotFound error variant from ConfigError, as header lookup errors are now handled by standard error paths. [1] [2]
  • Minor code cleanups, such as using into_std_path_buf() for path conversion and updating imports. [1] [2]

These changes collectively make error handling more robust and the code easier to maintain and extend.


References: [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]

@wmmc88 wmmc88 changed the title Adopt IoError with metadata and optimize path creation in wdk-sys build.rs feat: enhance error handling with IoError and IoErrorMetadata for improved std::io::Error diagnostics for fs errors Aug 26, 2025
Copilot AI review requested due to automatic review settings September 12, 2025 03:56
Copy link
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 pull request enhances error handling in the wdk-build crate by introducing dedicated IoError and IoErrorMetadata types for I/O operations, providing better context for filesystem-related failures.

  • Introduces new error types (IoError and IoErrorMetadata) to wrap std::io::Error with detailed path context
  • Refactors all filesystem operations throughout the codebase to use these enhanced error types
  • Updates error handling in binding generation and file operations to capture and propagate path metadata

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
crates/wdk-sys/build.rs Updates bindgen file generation to use IoError with path metadata for write operations
crates/wdk-build/src/utils.rs Converts filesystem operations to use IoError with path context for directory reading
crates/wdk-build/src/lib.rs Defines new error types and refactors include/library path validation to use enhanced error handling
crates/wdk-build/src/cargo_make.rs Updates path resolution and file operations to use IoError with detailed path metadata

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copilot AI review requested due to automatic review settings September 15, 2025 03:15
Copy link
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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@wmmc88 wmmc88 marked this pull request as ready for review September 23, 2025 02:57
@wmmc88 wmmc88 requested review from a team and Copilot September 23, 2025 02:57
Copy link
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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@krishnakumar4a4 krishnakumar4a4 left a comment

Choose a reason for hiding this comment

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

Left a few comments.

@wmmc88 wmmc88 self-assigned this Oct 2, 2025
@wmmc88 wmmc88 added the next-release-priority Issues and PRs that should be prioritized to be in the next crates.io release label Oct 2, 2025
Copilot AI review requested due to automatic review settings October 3, 2025 20:37
Copy link
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

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copilot AI review requested due to automatic review settings October 3, 2025 21:09
Copy link
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

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


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@wmmc88 wmmc88 requested review from a team, gurry and krishnakumar4a4 October 3, 2025 21:13
@wmmc88 wmmc88 added this pull request to the merge queue Oct 6, 2025
Merged via the queue into microsoft:main with commit 1654efe Oct 7, 2025
229 checks passed
@wmmc88 wmmc88 deleted the io-error-metadata branch October 7, 2025 01:54
@leon-xd leon-xd mentioned this pull request Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

next-release-priority Issues and PRs that should be prioritized to be in the next crates.io release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants